美文网首页
Android 蓝牙 pin 自动配 setPin()方法有时候

Android 蓝牙 pin 自动配 setPin()方法有时候

作者: 吃货养成记 | 来源:发表于2018-08-09 15:43 被阅读241次

2018-08-09

Android  蓝牙pin自动配对ClsUtils类中的 

static public boolean setPin(Class btClass, BluetoothDevice btDevice,

                                String str){

try{

 Method removeBondMethod = btClass.getDeclaredMethod("setPin", new Class[]{byte[].class});

 Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice,

       new Object[]{str.getBytes()});

              return returnValue.booleanValue();

        }catch (Exception e){   e.printStackTrace();return false;

        }

    }

输入错误的pin 返回也是true,实际蓝牙并没有配对成功 btDevice.getBondState()== BluetoothDevice.BOND_BONDED???为什么,如何解决

相关文章

网友评论

      本文标题:Android 蓝牙 pin 自动配 setPin()方法有时候

      本文链接:https://www.haomeiwen.com/subject/fyccbftx.html