Android Question upgrade to new SDKs + foreground tracker - right aproach

Tomas Petrus

Active Member
Licensed User
Longtime User
Hi Guys,
I am upgrading my app to new SDKs and I have to changed lot of stuff. everything seems to work eventualy.

But the app (services, process ?) got killed after 10-15 minut after the phone is locked.
testing on Android 9+

I were following the new Tracker tutorial + foreground app tutorial.

According to one of Erel notes I have moved all the important variables to Starter Process_Globals and access them from Tracker and Activity.
Because process should be immortal and Starter too.

Whats happening now is that:
- The app got killed and and bridge logger stop working without any previous notice or error
- Then it starts again I assume when this line in Tracker ticks
B4X:
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
- can it be shorter ? like 5 minutes? It do always restart ? or start the service only when the service is not runing ? and if its not runing do nothing ?

- but it start just partialy it seems like after 2. start I am missing then some variables for sure I am missing those stored in object Ridici that is defined in Starter service

B4X:
Sub Process_Globals
     Public Ridic As RidicCs 'using class in class module
End Sub

Sub Service_Create
    Ridic.Initialize
End Sub
The values are pulled from the server after login and set in Activity after login

Its hard to tell whats happening exactly without logs.
Same behavior in debug and release.

Any ideas ?
thx
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
you should run the app in RELEASE, not debug
As I wrote I have been testing both debug and RELEASE, there is The BridgeLogger for release mode .. that I was pointing to.

no. Android prevent you doing this.
what is the shortest interval - if it get killed after 10-15 min I cant wait another 15-20 minut to start it again...even if I fix the missing values

Older solution was more persistent...
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
I have started with the link you mentioned.

After some more testing, on Android 8+ your and mine app is working well.
On 9+ both apps got killed when the phone is locked, sometimes even when just calling etc..

edit: regardless what you do when the Activity is on background after some time the services got killed too. shortening the time of StartAt from 30m to 10m seemed to improve it a little bit..
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
i am happy to disagree :))

1.take all variables except constants from process_global and stored them in kvs.
2. Servicestartat changed from 30 to 5 minutes.

And it seems persistent.

Just curious is there need to check if service is running ? For startserviceat ? Or it is doing automaticaly so there is never more instances ?
 
Upvote 0
Top