Android Question Bluetooth Connection Service to Paired Bluetooth Serial Device

Discussion in 'Android Questions' started by Dale_Schroeder, Feb 18, 2015.

  1. Dale_Schroeder

    Dale_Schroeder New Member Licensed 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.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should handle AsyncStreams terminated and error events.
     
  3. Dale_Schroeder

    Dale_Schroeder New Member Licensed 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?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice