Android Question Service is not terminated

D

Deleted member 103

Guest
Hi,

Can someone tell me why the service is not finished?
In the sub "Activity_Pause" it should be terminated but will not (see screenshot).
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
'        Log("UserClosed=" & UserClosed)

        mBBL.goWriteIniFile
       
        PhoneAwake.ReleaseKeepAlive

        'Bluetooth verbindung aufheben
        Starter.bluetooth.DestroyConnection

        If Starter.GPS1.GPSEnabled Then
            Starter.GPS1.stop
            Starter.GPS_On = False
        End If   
       
        'Service beenden
        StopService(Starter)
        StopService(smAtomtime)
       
        ExitApplication
    Else
        Starter.IsStartEnabled = tbtnStart.Enabled
    End If
End Sub

speedpilot.png
 
D

Deleted member 103

Guest
Do you mean that it is not processed in this order?
B4X:
        'Service beenden
        StopService(Starter)
        StopService(smAtomtime)
      
        ExitApplication
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are trying to solve a non-existent problem. By doing so you are adding real problems to your app.

1. It is a mistake to call ExitApplication (in almost all cases).
2. You don't need to worry about services kept alive by the OS. This is the responsibility of the OS to kill the process when the app is in the background.

Do you mean that it is not processed in this order?
StopService, like StartService and StartActivity, sends a message to the system. Only when this message is processed will the service be stopped.
 
Upvote 0
D

Deleted member 103

Guest
1. It is a mistake to call ExitApplication (in almost all cases).
I have noticed that without "ExitApplication" my GPS is often not terminated, so I try to finish everything manually. :(
 
Upvote 0
D

Deleted member 103

Guest
Hi Filippo
There must be something odd in you code. I have seen that if I start twice the GPS in same process and terminate it only once the GPS continues to work.
Check your code...
Thanks, I'll have to check.
 
Upvote 0
Top