How to pair Bluetooth device programmatically Android

前端 未结 8 2002
不知归路
不知归路 2020-11-27 12:35

I am developing an application where I want to connect a Bluetooth device main issue is I don\'t want user to enter required pin instead application should do that by himsel

8条回答
  •  生来不讨喜
    2020-11-27 13:25

    Try this,

    BluetoothDevice device = intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE");
    device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device, true);
    device.getClass().getMethod("cancelPairingUserInput", boolean.class).invoke(device);
    

提交回复
热议问题