Android Question Why not start again Stater service after close from recently app?

Pooya1

Active Member
Licensed User
Hi
All of things is good
Problem is when user close app from recent app but starter service not start again
I have problem in android 8 and i dont test in below 8 version android
But android 8 is very important
Because i connect to b4j socketserver in starter and it must be connect to server after close app
Thanks
 

Pooya1

Active Member
Licensed User
Problem was solved
I start again Starter service with :
B4X:
StartServiceAt("",DateTime.Now + 2000,True)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Android will kill your app if you want to restart your service 2 Seconds after it finishes
You should not start (or stop) the Starterservice manually.
 
Upvote 0

Pooya1

Active Member
Licensed User
Android will kill your app if you want to restart your service 2 Seconds after it finishes
You should not start (or stop) the Starterservice manually.
But i use it and didn't have any problem in android 8
If my way is mistake so what way do i use it? i need service start again
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I have problem in android 8
But i use it and didn't have any problem in android 8
Then this time something in your code should be wrong, do not you agree?

B4A 8.30 helps to keep the Starter service alive:
Starter service is never destroyed until the process is killed - if you carefully read the automatic foreground notifications tutorial then you should be aware to a significant behavioral change in Android 8+. The OS kills services while the app is in the background. In previous versions the OS never killed specific services (only the complete process). This change made it much more difficult to work with the starter service as you could no longer assume that the starter service is running.
Starting from B4A v8.3 the starter service will never be paused until the process is killed. Internally it switches from the service context to the application context.
 
Upvote 0

Pooya1

Active Member
Licensed User
As far as I know it should remain active. Have you tried a half-empty project?
I do not have Android 8 (I have an Android 7 and I'm waiting for the manufacturer to provide the update :mad:)
:D
No in android 7 and below i dont have problem
Problem is in android 8 that i try start again Starter service and it is working now :cool:
 
Upvote 0

Pooya1

Active Member
Licensed User
I meant: have you tried-tested a simply new half-empty project on your Android 8?

Just to check if even with this "app", removing it from "recents", the starter does not restart.




Have to watch Sevilla - Barcelona (football) now :)
I test in empty project and remove app from recent but starter not start again
 
Upvote 0

Pooya1

Active Member
Licensed User
The process is killed when the user swipes it from the recent apps list. There is no reason for the starter service to start again.

You can make your service a foreground service. This way the process will not be killed and it will keep running.
If i foreground service,dont show notification in statusbar in starter service?
 
Upvote 0
Top