Android Question GPS when display turn off

Angelo Pagone

Member
Licensed User
Hi,
I'm trying the GPS demo. When the display turns off the application no longer detects changes of position.
I need the continuous application running in the background.
How can I do?

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
How can I do?
Start with using the forumsearch. Exact this is answered a lot of times.

Use a foreground service (for the gps-code) together with a partial wake lock to prevent android from going into sleep
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
B4X:
Sub Service_Create
    sNotif.Initialize
    sNotif.Icon = "icon"
    sNotif.Vibrate=False
    sNotif.SetInfo2("GPS","Service Running","FromNotification",Main)
    sNotif.Sound = False
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)
    GPS1.Initialize("GPS")

...

Service.StartForeground(1,sNotif)


This is how you start the GPS service as a foreground service (a notification is a MUST -> user knows that your app is running)
 
Upvote 0
Top