Android Question Bluetooth Connection Service to Paired Bluetooth Serial Device

Dale_Schroeder

New Member
Licensed User
Longtime User
Hey Everyone,

I am having some troubles figuring out how to see if a specific bluetooth device is connected or not. I need to monitor the state of a bluetooth connection.

I will be running this in a service. The Activity will pair and connect with the spp device originally but then the service needs to know if the device is connected or is offline.

I have read some articles but don't know how to use the (intents and getextras) properly

Constant Value: "android.bluetooth.device.action.ACL_CONNECTED"
or
Constant Value: "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED"

Because i am using a SPP serial Connection using Astream. The service must know if the device is connected. If the device is connected then it can reopen the stream. but if the device disconnects it needs to know that so it can close the stream so it doesn't crash the astream.
 

Dale_Schroeder

New Member
Licensed User
Longtime User
Do you have an example of how this can be done? how i can have a flag that is set if the BT Device is Online and cleared if the device is not?
 
Upvote 0
Top