【问题标题】:Remove Bluetooth Pairing Request Prompt删除蓝牙配对请求提示
【发布时间】:2018-08-10 07:11:47
【问题描述】:

所以我的设备是静音设备。我想要的是,当我从不同的设备向 khadas 发送配对请求时,设备会自动配对。问题是当发送蓝牙配对请求时,会出现带有密码的配对确认提示。我已经设置了一个广播接收器from here,但似乎没有任何工作代码是:

private final BroadcastReceiver mPairingRequestReceiver = new BroadcastReceiver()
    {
        public void onReceive(Context context, Intent intent)
        {
            Log.v("BDE", "recieved something!");
            String action = intent.getAction();
            if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST))
            {
                try
                {
                    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                    int pin = intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY", 1234);
                    //the pin in case you need to accept for an specific pin
                    Log.d(TAG, "Start Auto Pairing. PIN = " + intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY", 1234));
                    byte[] pinBytes;
                    pinBytes = ("" + pin).getBytes("UTF-8");
                    device.setPin(pinBytes);
                    //setPairing confirmation if needed
                    device.setPairingConfirmation(true);
                } catch (Exception e)
                {
                    e.printStackTrace();
                    Log.e(TAG, "Error occurs when trying to auto pair");
                    e.printStackTrace();
                }
            }
        }
    };

当我运行此代码时,我收到错误“原因:java.lang.SecurityException:需要 BLUETOOTH PRIVILEGED 权限:用户 10068 和当前进程都没有 android.permission.BLUETOOTH_PRIVILEGED。”

我在 Android Manifest 中也添加了权限,并将应用程序安装为系统应用程序,但仍然无法使用。

【问题讨论】:

    标签: android bluetooth


    【解决方案1】:

    找到解决方案,如果您具有 root 访问权限并且您正在将应用程序安装为系统应用程序以获得 bluetooth_privileged 权限。将 apk 复制到 /system/priv-app 而不是 /system/app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-21
      • 2015-05-15
      • 2016-09-14
      • 1970-01-01
      • 2018-05-26
      • 1970-01-01
      • 2015-06-09
      相关资源
      最近更新 更多