Android Question Distinguish bluetooth connection/disconnection from start service at


Well-Known Member
Licensed User
Longtime User
Hi everyone,

I have the question as described in the subject.

I have this code in manifest:

AddReceiverText(sBT, <intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>

And this code in StartService

    If StartingIntent.Action = "android.bluetooth.device.action.ACL_CONNECTED" Then
        bIn = True
    Else If StartingIntent.Action = "android.bluetooth.device.action.ACL_DISCONNECTED" Then  
        bIn = False
    End If

It works perfect and detects bluetooth connection and bluetooth disconnection.
The problem is that Android 8.1 kills the service after some time and to face that I use the StartServiceAt. My question is if there is a way to distinguish if the service was started from bluetooth connection/disconnection or from StartServiceAt in order to run different code in each case...

Thanks in advance