Sriraman
Sriraman

Reputation: 7937

How to find the reason for Bluetooth pairing failure in Android?

I'm trying to pair a device using Bluetooth. Sometimes pairing is working fine. but, sometimes createBond() function returns false. How to find the reason for the failure?

if(!device.createBond()){

     // want to find the reason for the failure

}

Upvotes: 4

Views: 3307

Answers (2)

aiden_fry
aiden_fry

Reputation: 304

This negative result can be caused when calling createBond() on an already bonded device. Remember that bonded does not mean connected, bonded means paired. Check if your device bluetooth settings already has a known configuration for the device you are trying to connect to. If so, deleting the Bluetooth configuration and then doing createBond will fix the problem.

Upvotes: 9

Sriraman
Sriraman

Reputation: 7937

I found the reason for the error in my scenario. I got this error when I'm tried to pair an already paired device.

Now, I have added the check before it to check whether it is the paired device or not. It is working fine for me now.

Upvotes: 1

Related Questions