Android Question Service always running

Upvote 0
Sorry, that is my mistake.
Now i change like this.
Code: Copy
Sub Service_Destroy
  
    StartServiceAt("",DateTime.Now + 10 * 1000, True)

End Sub

But when i lock screen it will be kill again.
 
Upvote 0
I did several attempts.
I tried the code on different devices, android 4, 4.20, 5, 5.1 and 6

This anomaly occurs only on Huawei with Android 6.0

So I suppose either the version of Android or the Huawei firmware is the same as Honor

StartServiceAt is good solution
 
Last edited:
Upvote 0
I tried on an Asus ZenFone 2 with Android 6.01 and it works correctly. The operating system kills the app but the service stays sticky, so it works properly.
 
Upvote 0
You should use File - Export as zip when uploading to the forum.

The task manager kills the process so the service stops. The only thing that you can do, which might help, is to periodically call StartServiceAt to cause the Notification service to start again.
Sorry, why I'd call StartServiceAt instead of making my service a "sticky" service? Making a service "sticky" using
#StartCommandReturnValue: android.app.Service.START_STICKY

should restart my service if someone will kill it, right?
 
Upvote 0
It is not instead of a sticky service. You can make the service both sticky and use StartServiceAt to ask the OS to start it from time to time.

Background processes are becoming more and more restricted in newer versions of Android.
But I have read that a service should restart if someone will kill it, right?
 
Upvote 0
Back
Top