Android Question GPS location

gif

Member
Licensed User
Hello,
Starting from the example program 'my location', at each notification, I record the position; this works well but when the smartphone goes to sleep or when another application is launched, the application does not work anymore and does not restart automatically.

If it seems normal on android that an application doesn't work anymore when it's not in the foreground (too bad!), if this is possible, how to make the application continue to work even when it's not in the foreground, or, how to make it restart automatically when it's not in the foreground.

In Service_Create, there is indeed
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
GPS.Initialize("gps")
lock.PartialLock
and in Service_Start (StartingIntent As Intent)
Service.StartForeground(nid, CreateNotification(""))
StartServiceAt(Me, DateTime.Now + (10 * DateTime.TicksPerMinute), True)
Track

Thank you in advance for your answer.
 

Alex_197

Well-Known Member
Licensed User
Longtime User
When the app restarts Starter event SericeCreate fired. So you can check in this event and start gps again.
 
Upvote 0
Top