How to programmatically pair a bluetooth device on Android

后端 未结 10 1914
轻奢々
轻奢々 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:39

    May be you need to startActivityForResult instead of only startActivity?

    Other option is to look into the BluetoothChat application sample and start an RFComm connection socket, as soon as you start the socket a pairing request will automatically appear without needing to send a separate intent for pairing. This way you won't need to handle pairing.

    http://developer.android.com/resources/samples/BluetoothChat/index.html

提交回复
热议问题