配对请求 - 不从uid 1000导出

时间:2014-08-05 11:53:11

标签: android bluetooth uid

我尝试打开一个特定MAC地址的配对对话框。

BluetoothDevice device;
String bt_mac = read.toUpperCase(Locale.GERMAN);
device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bt_mac);
Intent intent = new Intent("android.bluetooth.device.action.PAIRING_REQUEST");
intent.putExtra("android.bluetooth.device.extra.DEVICE", device);
intent.putExtra("android.bluetooth.device.extra.PAIRING_VARIANT", 0);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

但我收到的只是这条错误信息:

  

java.lang.SecurityException:Permission Denial:启动Intent {   act = android.bluetooth.device.action.PAIRING_REQUEST flg = 0x10000000   cmp = com.android.settings / .bluetooth.BluetoothPairingDialog(有   来自ProcessRecord的额外内容} {434110a0 15553:de.test.testapp / u0a10003}   (pid = 15553,uid = 10003)未从uid 1000

导出

我认为问题就在于消息的这一部分:不是从uid 1000导出的 但我不知道如何解决它

1 个答案:

答案 0 :(得分:0)

根据AndroidManifest.xml,配对请求属于"特殊广播,只有系统可以发送":

    <protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" />

我猜其他用户提出此解决方案(例如在this问题中)可能具有root权限。