Android Question Getting Connected Bluetooth Device Details?

Discussion in 'Android Questions' started by Mark Hollingworth, Jul 21, 2015.

  1. Mark Hollingworth

    Mark Hollingworth Member Licensed User

    I am trying to find a way for my app to be able to query a bluetooth device name and address when it starts up, if the device is already connected, using the stock bluetooth connection (turn on bluetooth through android settings and select the device to connect too). I know I can do this with intents when a device connects, using a service and listening for the CONNECTED intent but if I stop the service then start it again the CONNECTED intent is not fired if the bluetooth device is already connected.

    So my question is can you get the details of a bluetooth device that is already connected when an app starts up?
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Mark Hollingworth

    Mark Hollingworth Member Licensed User

    Thanks Erel,

    So basically the answer is no you cant query a connected Bluetooth device without using the CONNECTED Intent.

    I know about Static intents and do already have them setup as a service. Maybe I didn't explain myself properly I am thinking about the situation (might only happen once) when an app is first installed, the services have not been run before but the Bluetooth is already connected to a device, the service spins up but it wont get called as the intent has already been fired before the app started so there is no record of it, using BluetoothAdmin I can see that Bluetooth is enabled but cannot see if there is anything actually connected.

    Is the only solution to ask the user to reconnect the Bluetooth so that the service can then pick up the CONNECTED Intent and pull out the connected device details or show a list of all the Paired devices and asking them to select which is connected?

    If StartingIntent.Action = "android.bluetooth.device.action.ACL_CONNECTED" Then
    Dim io As JavaObject = StartingIntent
    Dim bd As JavaObject = io.RunMethod("getParcelableExtra"Array As Object("android.bluetooth.device.extra.DEVICE"))
           ConnectedDeviceName = (bd.RunMethod(
           ConnectedDeviceAddress = (bd.RunMethod(
    End If
  4. Erel

    Erel Administrator Staff Member Licensed User

    I don't think that there is any other way to find the connected devices.
    Mark Hollingworth likes this.
  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