G K
G K

Reputation: 21

Android Programmatically Bluetooth Pairing

I would like to programmatically pair my mobile phone with medical sensor using Bluetooth interface. I have address and PIN necessary for connecting to device but I would like to avoid user interaction (pairing process - sensor configuration etc.)

I tried using unofficial Bluetooth API (http://code.google.com/p/android-bluetooth/) but it seems that this doesn't for Android 2.1 and above (I got LocalBluetoothDevice allways NULL, and people on their forum said that this is only for 1.X versions)

I saw that Android API has methods that do this pairing in background but they are labeled with @hide annotation. How do I access this?

Did anyone succeeded in this? (programmatically pairing) Any example?

Thanks!

Upvotes: 2

Views: 11856

Answers (1)

daveD
daveD

Reputation: 976

I think you need to use createInsecureRfcommSocketToServiceRecord() which is introduced in API 10. I've got to get this working on Android 2.2, so I used reflection to call the method as per this method & it worked. I am identifying the Bluetooth device I connect to by its friendly name & setting it to not require PIN bonding, my Android APP now connects to it without the device having to be bonded or any PIN input, so its a security concern.

Upvotes: 2

Related Questions