Android Question Background Service

Paul Garcia

Member
Licensed User
Longtime User
Good afternoon Erel, I have a problem with the GPS in the background after two minutes it stops working I have tried another version of Android (under 9) and there it works for up to an hour. your help please. Background Service.
I used the Mylocation.zip example that was in the forum but in my version of android 9 it stops within two minutes
1579294821242.png


just add an insert to the base to see the time in which it entered. but after a minute I didn't keep
 

JohnC

Expert
Licensed User
Longtime User
Even though this is probably not causing a problem now, it is good practice to add parentheses to make sure the math is done properly so it doesn't try to add 10 to .Now THEN multiply the RESULT of that by TicksPerSecond:

B4X:
If DateTime.Now > LastUpdateTime + (10 * DateTime.TicksPerSecond) Then
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Even though this is probably not causing a problem now, it is good practice to add parentheses to make sure the math is done properly so it doesn't try to add 10 to .Now THEN multiply the RESULT of that by TicksPerSecond:

B4X:
If DateTime.Now > LastUpdateTime + (10 * DateTime.TicksPerSecond) Then

Makes it a lot easier to read as well.

Good afternoon Erel, I have a problem with the GPS in the background after two minutes it stops working I have tried another version of Android (under 9) and there it works for up to an hour.

I can't fully remember that example on the forum, but are you (or the example) using using partial lock???
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
HI
Have you implemented everything according to this example?
 
Upvote 0

Paul Garcia

Member
Licensed User
Longtime User
HI
Have you implemented everything according to this example?
It's the same example but it doesn't work more than two minutes in the background
 
Upvote 0
Top