Android Question Distinguish bluetooth connection/disconnection from start service at

hatzisn

Expert
Licensed User
Longtime User
Hi everyone,

I have the question as described in the subject.

I have this code in manifest:

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

And this code in StartService

B4X:
    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
 

hatzisn

Expert
Licensed User
Longtime User
Thanks DonManfred. I will try it immediately.

Edit: Once again you were correct DonManfred. Thanks.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…