If you are working on an Android Java/Kotlin code and trying to use the Bluetooth device of the phone and while running the app you get a Runtime Exception saying "Unable to start activity Need BLUETOOTH permission", well then you have missed adding the user permission to provide access to Bluetooth, add the below line in the AndroidManifest.xml file under the manifest node,
<uses-permission android:name="android.permission.BLUETOOTH" />
Error Stack trace:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.code2care.testing/com.code2care.testing.MainActivity}:
java.lang.SecurityException: Need BLUETOOTH permission:
Neither user 10123 nor current process has android.permission.BLUETOOTH.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
Caused by: java.lang.SecurityException: Need BLUETOOTH permission:
Neither user 10123 nor current process has android.permission.BLUETOOTH.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at android.bluetooth.IBluetooth$Stub$Proxy.isEnabled(IBluetooth.java:853)
at android.bluetooth.BluetoothAdapter.isEnabled(BluetoothAdapter.java:701)
at com.code2care.testing.MainActivity.isBluetoothEnabled(MainActivity.java:26)
at com.code2care.testing.MainActivity.onCreate(MainActivity.java:17)
at java.lang.reflect.Method.invoke(Native Method)
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:
- Fix: ReferenceError: require is not defined in ES module scope [Node] - JavaScript
- Fix - JioCinema Something Went Wrong Please Try Again Error 8001 while streaming IPL Cricket Live - HowTos
- Call a Stored Procedure using Java JDBC CallableStatement Example - Java
- Generate Maven Project Dependency Tree using MVN Command - Java
- What Java version is used for Minecraft 1.18 - Java
- Google Colab: How to read file from Google Drive - Google
- Shortcuts: How to Toggle Word Wrap in Visual Studio Code (VS Code) - Shortcuts
- How to Whitelist IP Address on GoDaddy Hosting? - HowTos