小编use*_*231的帖子

Android蓝牙配对安全

自从我升级到android 4.2后,当我尝试配对设备时我遇到了问题设备应该配对但现在它说需要across_user_permission.

这是错误日志:

错误:代码3:
java.lang.SecurityException ::
Permission Denial:来自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;
}
Run Code Online (Sandbox Code Playgroud)

android android-bluetooth pairing

6
推荐指数
1
解决办法
572
查看次数

标签 统计

android ×1

android-bluetooth ×1

pairing ×1