【发布时间】:2014-02-18 14:45:06
【问题描述】:
自从我升级到 android 4.2 后,我在尝试配对设备时遇到了问题 设备应该已配对,但现在它说需要 cross_user_permission。
这是错误日志:
错误:代码 3:
java.lang.SecurityException::
权限拒绝:来自 android 的广播要求以用户 -1 身份运行,但 来自user0的调用;这需要
android.permission.INTERACT_ACROSS_USERS_FULL 或
android.permission.INTERACT_ACROSS_USERS。
这里是我的方法:
public boolean ensurePaired(BluetoothDevice bd) {
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(bd.getAddress());
boolean paired = false;
Log.d(TAG,"Pairing with Bluetooth device with name " + device.getName()+" and address "+device.getAddress());
try {
Method m = device.getClass().getMethod("createBond");
paired = (Boolean) m.invoke(device);
} catch (Exception e)
{
return paired;
}
Log.d("BluetoothPlugin -", "Returning "+ "Result: "+paired);
return paired;
}
【问题讨论】:
标签: android android-bluetooth pairing