Skip to content

In GetLocationBackground sample, what is the purpose of the timer? #1

@CantStopMyBrain

Description

@CantStopMyBrain

Thanks for this code sample and the article in Medium (https://thakkarkomal009.medium.com/update-location-in-background-using-foreground-service-android-7aee9de1a6d6) -- I have been trying to figure out a reliable way to do continuous location tracking for a public-safety application and this looks very promising.

Your article does not mention the timer you are using in the LocationService class and it's not clear to me whether it is doing anything essential in terms of keeping the Service alive or the Location updated... I don't think so, but I wonder if I'm missing something. I can remove all the timer-related code and the app still seems to function, including the logcat output indicating location updates. Is there any reason to include the timer in the app to ensure reliable "perpetual" location tracking?

Ahhh... I spoke too soon! Eventually in the run without the timer the Service dies and the UI stops responding. Can you explain this behavior? Running the location update request doesn't happen within the service so it looks like the service is idle or complete?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions