如何实现android蓝牙自动配对连接?

// 自动配对设置Pin值static public boolean autoBond(Class btClass, BluetoothDevice device, String strPin) throws Exception {Method autoBondMethod = btClass.getMethod("setPin", new Class[] { byte[].class });Boolean result = (Boolean) autoBondMethod.invoke(device, new Object[] { strPin.getBytes() }); return result;} // 开始配对static public boolean createBond(Class btClass, BluetoothDevice device) throws Exception {Method createBondMethod = btClass.getMethod("createBond");Boolean returnValue = (Boolean) createBondMethod.invoke(device); return returnValue.booleanValue();}

使用上面的代码可以实现配对,但是会出现输入提示框(点击取消后,查看配对是已配对)

我想屏蔽这个提示框,那为大神知道怎么做了?或者使用其它方式实现匹配

下面是进行匹配时 弹出提示框的日志,我想如果我不能屏蔽它,那么我可以通过代码关闭它吗

05-18 17:26:54.779: I/BluetoothEventLoop.cpp(171): agent_event_filter: Received method org.bluez.Agent:RequestPinCode

05-18 17:26:54.790: I/ActivityManager(171): Starting: Intent { act=android.bluetooth.device.action.PAIRING_REQUEST flg=0x10000000 cmp=com.android.settings/.bluetooth.BluetoothPairingDialog (has extras) } from pid 252

05-18 17:26:55.190: I/ActivityManager(171): Displayed com.android.settings/.bluetooth.BluetoothPairingDialog: +374ms

原文链接:https://www.oschina.net/question/106603_54246


分享到:


相關文章: