1

I have the need to detect if a certain mac address is connected or in range, if it is then my app assumes that you are for example at home or in your car.

From my reading on the Bluetooth docs, it all seems more to scan and try pair / connect with new devices. I don't want to do this, Just detect if a device is in range or connected. I will know the mac address up front.

for example:

if(BluetoothAdapter.IsConnectedTo("MAC ADDRESS"))
{
Toast.makeText(this,"You are in your car",Toast.Short).show();
}

In other questions they say I should set a broadcast intent for onConnected and on disconnect. However this will only trigger when connecting, This wont help me if the device is already connected.

The other option they scan for discover-able devices, But this does not show me if the phone is currently connected to that specific device?

Zapnologica
  • 22,170
  • 44
  • 158
  • 253
  • Possible duplicate of [How to scan for available bluetooth devices in range in android?](https://stackoverflow.com/questions/3170805/how-to-scan-for-available-bluetooth-devices-in-range-in-android) ...there's no need to pair/trust/connect, but the Adapter needs to scan. hint: there are also NFC tag stickers, eg. for the car. – Martin Zeitler Jul 18 '18 at 06:33
  • Possible duplicate of [How to programmatically tell if a Bluetooth device is connected? (Android 2.2)](https://stackoverflow.com/questions/4715865/how-to-programmatically-tell-if-a-bluetooth-device-is-connected-android-2-2) –  Jul 18 '18 at 07:02
  • 1
    Neither of these work. The one method only tells you when it connects or disconnects, This doesn't help me if It is already connected. The second option just tells me if its discover able, not if its currently connected? – Zapnologica Jul 18 '18 at 10:16

0 Answers0