android蓝牙自动配对的有关问题


android蓝牙自动配对遇到是SSP配对时,那种只弹出“蓝牙配对申请”框,只需要点击“配对”和“不配对”,这时候我的广播监听函数如下

  public class MessageReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
    if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
         BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
         try {
             BtConnectOperation.BtSetPairingConfirmation(device.getClass(), device);
         } catch (Exception e) {
             // TODO Auto-generated catch block
     e.printStackTrace();
         }
         mConnService.pairEnd();
    }
}
}


其中这个BtSetPairingConfirmation函数如下,使用反射机制

  //设置确定
    static public boolean BtSetPairingConfirmation(Class btClass, BluetoothDevice device)
     throws Exception {
        Method SetPairingConfirmationMethod = btClass.getMethod("setPairingConfirmation", 
         boolean.class);
        Boolean returnValue = false;
        returnValue = (Boolean)SetPairingConfirmationMethod.invoke(device, true);
        
        return returnValue;
    }


为何还是不能直接自动配对呢,还是会弹出“蓝牙配对申请”框,请大神们给些意见,谢谢啊 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章