[Android] RuntimeException: Unable to start activity Need BLUETOOTH permission


Android Bluetooth error
Android Bluetooth error

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)



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.