java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission

前端 未结 5 2280
天涯浪人
天涯浪人 2021-02-19 22:12

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

j

相关标签:
5条回答
  • 2021-02-19 22:35

    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).

    0 讨论(0)
  • 2021-02-19 22:38

    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.

    0 讨论(0)
  • 2021-02-19 22:39

    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

    0 讨论(0)
  • 2021-02-19 22:47

    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.

    0 讨论(0)
  • 2021-02-19 22:56

    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

    0 讨论(0)
提交回复
热议问题