How to programmatically pair a bluetooth device on Android

后端 未结 10 1942
轻奢々
轻奢々 2020-11-30 23:27

For my application I\'m trying to programmatically pair a bluetooth device. I\'m able to show the pairing dialog for the device I want to pair and I can enter a pincode. Whe

10条回答
  •  生来不讨喜
    2020-11-30 23:53

    This is how I get it:

    Bluetooth device = mBtAdapter.getRemoteDevice(address);
    //address:11:23:FF:cc:22 
    Method m = device.getClass()        
     .getMethod("createBond", (Class[]) null);
             m.invoke(device, (Object[]) null); // send pairing dialog request
    
    After pairing//
           connectDevice(address);
    

提交回复
热议问题