Android.provider.Settings.ACTION_BLUETOOTH_SETTINGS crash on Samsung

Does anyone know why

Intent pairIntent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); startActivityForResult(pairIntent, 0); 

Crash on all Samsung devices, but works fine on emulator, HTC, Sony, LG, etc.

EDITED -----------------------------------

Turns out Samsung also requires BLUETOOTH_ADMIN in the manifest

 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 
+2
source share
1 answer

If you have an application in production, you need to have something that will allow you to get crash logs. This can be the default material that you receive from delivery through the Play Store, or an open source solution, such as ACRA, or any number of service providers.

As for your accident, there is no guarantee that this activity is available. Documentation citation:

In some cases, the corresponding activity may not exist, so you must be protected from this.

To protect, you could wrap your startActivity() call in an exception handler by observing an ActivityNotFoundException .

Also note that you are using startActivity() , not startActivityForResult() , with this Intent action. Again, quoting the documentation :

Exit: nothing.

This means that there is no result, and using startActivityForResult() is a waste of time.

+2
source

All Articles