Search code examples
javaandroidgeolocation

Android - Access location in background without opening app


I'm relatively new to using location services in Android, and I am wondering how it is possible to have my app check my location (without opening the app) and executing some code, for example based on if my latitude or longitude is greater than 50. Is there a common way of running the app (including location services) in the background?


Solution

  • What you are looking for is to build an Android Service

    Service is a program that runs in the background and can do all kind of tasks including accessing the location services

    Check out the code published here for a detailed answer.