Android Question Distinguish bluetooth connection/disconnection from start service at

Discussion in 'Android Questions' started by hatzisn, Apr 1, 2019.

  1. hatzisn

    hatzisn Active Member Licensed User

    Hi everyone,

    I have the question as described in the subject.

    I have this code in manifest:

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

    Code:
    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
     
  2. DonManfred

    DonManfred Expert Licensed User

    startingintent.action will probably never ACL_CONNECTED or ACL_DISCONNECTED
     
    Erel likes this.
  3. hatzisn

    hatzisn Active Member Licensed User

    Thanks DonManfred. I will try it immediately.

    Edit: Once again you were correct DonManfred. Thanks.
     
    Last edited: Apr 1, 2019
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