19

Has anyone meet the same problem as the following error message shows when calling bluetoothDeive.createBond() method with android 4.4 api?

java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission

Note: BLUETOOTH_ADMIN permission is already included in AndroidManifest file.

3
  • 1
    Check is this permission will only work for system apps Commented Nov 14, 2013 at 9:46
  • Duplicate? stackoverflow.com/questions/15499388/… Commented Nov 14, 2013 at 10:05
  • No, the questions aren't related. You can't even request the BLUETOOTH PRIVILEGED permission as it is a privileged permission. Commented Apr 15, 2018 at 23:48

5 Answers 5

43

Got the exact error message.

Took me an hour to realize that the bluetooth on the phone is not enabled. After turning it on, it works as expected.

Sign up to request clarification or add additional context in comments.

4 Comments

So glad I read this - definitely saved me an hour! What a strange error to throw when Bluetooth is off, it has nothing to do with permissions... I guess the system tries to turn Bluetooth on but can't? Weird.
I refused to believe that that stack trace was due to my Bluetooth being off until I read your answer... I was like ... "surely cant be as stupid as that..."
I can't believe this was the problem!!! I turned my bluetooth off and spent about an hour scratching my head on runtime permissions haha
lol this litterly saved me an hour
22

You can't use this permission if your app is a third party app (non-system app). To learn more, see Android API: BLUETOOTH_PRIVILEGED

Comments

1

I run on this error, and only I can say, you need to install your app as a system privileged app, to go to system folder and try to copy app to the app folder or priv_app folder. On my Android platform, when I made folder inside priv_app folder for my app and copied my apk to it and restarted Android, everything worked OK. I my case I added in manifest all this permissions at the beginning, but it worked only after this step above.

Comments

-4

try this in your manifest

    <user-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

notice the user not uses-permission on the first line. Until I switched that, For some reason I kept getting

java.lang.SecurityException: Need BLUETOOTH_ADMIN permission

Comments

-4

Try this:

1) remove "android.permission.BLUETOOTH_PRIVILEGED" from your permissions.
2) remove "android.permission.BLUETOOTH".
3) add "android.permission.BLUETOOTH_ADMIN" and just that.

The reference says that is the only permission needed.https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#createBond()

EDIT: if you already included "bluetooth_admin", maybe its a platform problem.They may have not supported that functionality earlier. Maybe you should target a higher min-sdk-platform , Im using Android 20 as the minimum (but never tried that function).

1 Comment

What is the purpose of removing "android.permission.BLUETOOTH"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.