Need BLUETOOTH_PRIVILEGED permission

app能在5.0以前的系统上正常运行,但是在5.0以及更高的版本就不行了,每次去设置通知的时候,会报:Need BLUETOOTH_PRIVILEGED permission: Neither user 10157 nor current process has android.permission.BLUETOOTH_PRIVILEGED这种错误,我的清单文件里面已经添加了这个权限



确认配对的时候会需要 BLUETOOTH_PRIVILEGED


//
//                    //1.确认配对
//                    ClsUtils.setPairingConfirmation(btDevice.getClass(), btDevice, true);
                    //2.终止有序广播
                    Log.i(TAG,"order..."+ "isOrderedBroadcast:" + isOrderedBroadcast() + ",isInitialStickyBroadcast:" + isInitialStickyBroadcast());
                    abortBroadcast();//如果没有将广播终止,则会出现一个一闪而过的配对框。
                    //3.调用setPin方法进行配对...
                    Log.e(TAG,"BroadCast  aborted");
                    boolean ret = ClsUtils.setPin(btDevice.getClass(), btDevice, pin, context);

注释掉

ClsUtils.setPairingConfirmation(btDevice.getClass(), btDevice, true);

跳过确认配对这一步   就可以自动配对了

具体代码参考  http://www.jianshu.com/p/17164f5534ca



猜你喜欢

转载自blog.csdn.net/songyuequan/article/details/77879388