Android Question GPS when display turn off

Discussion in 'Android Questions' started by Angelo Pagone, Dec 16, 2016.

  1. Angelo Pagone

    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
     
  2. DonManfred

    DonManfred Expert Licensed User

    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
     
    KMatle likes this.
  3. Angelo Pagone

    Angelo Pagone Member Licensed User

    I'm sorry but I'm a beginner in mobile development.
    For me it is hard to find keywords for forum search.

    Thanks
     
  4. DonManfred

    DonManfred Expert Licensed User

    I see. Ok ;)

    You now have some keywords to search for ;)
     
  5. KMatle

    KMatle Expert Licensed User

    Code:
    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)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice