If you are getting the below error in the LogCat console when you run the Android application and it Unfortunately stops, its because you are trying to use Bluetooth that requires BLUETOOTH_ADMIN permission,
Error stack trace:
Process: com.code2care.testing, PID: 12310
java.lang.RuntimeException:
Unable to start activity ComponentInfo
{com.code2care.testing/com.code2care.testing.MainActivity}:
java.lang.SecurityException:
Need BLUETOOTH ADMIN permissicacheNameAndAddresson:
Neither user 10123 nor current process has android.permission.BLUETOOTH_ADMIN.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: java.lang.SecurityException:
Need BLUETOOTH ADMIN permissicacheNameAndAddresson:
Neither user 10123 nor current process has android.permission.BLUETOOTH_ADMIN.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.bluetooth.IBluetoothManager$Stub$Proxy.disable(IBluetoothManager.java:337)
at android.bluetooth.BluetoothAdapter.disable(BluetoothAdapter.java:1026)
at com.code2care.testing.MainActivity.toggleBluetooth(MainActivity.java:33)
at com.code2care.testing.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6543)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Solution
Make sure you have added the below permissions in the AndroidManifest.xml file,
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
More Posts related to Android,
- Increase Android Emulator Timeout time
- Android : Remove ListView Separator/divider programmatically or using xml property
- Error : Invalid key hash.The key hash does not match any stored key hashes
- How to Change Android Toast Position?
- Android Alert Dialog with Checkboxes example
- Android : No Launcher activity found! Error
- Android Development: Spinners with Example
- Failed to sync Gradle project Error:failed to find target android-23
- INSTALL_FAILED_INSUFFICIENT_STORAGE Android Error
- Disable Fading Edges Scroll Effect Android Views
- How to create Toast messages in Android?
- Channel 50 SMSes received every few minutes Android Phones
- Android xml error Attribute is missing the Android namespace prefix [Solution]
- Create Custom Android AlertDialog
- How To Disable Landscape Mode in Android Application
- Android Development - How to switch between two Activities
- incorrect line ending: found carriage return (\r) without corresponding newline (\n)
- Generate Facebook Android SDK keyhash using java code
- Android Error Generating Final Archive - Debug Certificate Expired
- 21 Useful Android Emulator Short-cut Keyboard Keys
- Android RatingBar Example
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020
- Download interrupted: Unknown Host dl-ssl.google.com Error Android SDK Manager
- fill_parent vs match_parent vs wrap_content
- Android : Connection with adb was interrupted 0 attempts have been made to reconnect
More Posts:
- Changing Android Intent Tittle using java code - Android
- Angular CLI ng Error: You need to specify a command before moving on. Use --help to view the available commands - HowTos
- Ubuntu Linux: Unzip a zip file using Terminal - Ubuntu
- Android Studio : Build Tools 23.0.0 rc1 is deprecated - Android-Studio
- Fahrenheit to Celsius Temperature Convertor: Tool & Formula - Tools
- 33: Python Program to send an email vid GMail - Python
- How to recover SharePoint FARM if the SQL Server IP changes - SharePoint
- [Fix] Ubuntu E: Unable to locate package sudo error - Ubuntu