Morphinz
Morphinz

Reputation: 261

Android: I can't get bluetooth paired device

I can discover devices and createbond. It's working fine. But when the user close the app and open again I'm already in bonded state and I only need open serial socket but I can't find the device!

GetBondedDevice gives all the device connected before and also the active one. Because of that I can't understand is it realy connected and ready to open serialsocket! Serial socket is not always active. I'm closing onDestroy or onPause to stop communicate.

To simplfy the question: I want to check if given mac address is paired and ready to open serial socket.

Upvotes: 2

Views: 506

Answers (1)

Youssif Saeed
Youssif Saeed

Reputation: 13375

As you mentioned, paired devices and connected devices are two different things as follows:-

  • Paired devices: these are devices that have exchanged security keys and are therefore 'linked' to your Android device (this makes the reconnection easier). These can be either connected or unconnected.
  • Connected devices: these are devices that have an active channel with your Android device that can be used to exchange data.

In your case, to get devices that have an active connection to your device, you can use the getConnectedDevices or getConnectionState.

You can find more references here:-

Upvotes: 2

Related Questions