Search code examples
androidgpsnotificationslocationflashlight

Notification when I'm near a stored location


I currently write on an app which should give me information about the places in my area. I've already built a function that indicates how far a user is away from a location (via GPS).

Now I want that the user gets an information at a certain distance to a place (eg 20 meters).

For that I have the following questions:

  1. How can I get that the app continues in the background (including GPS) and checks the current distance to a place?
  2. How can I find / notify the user when he/she is in the vicinity of a place and the app itself is only running in the background (eg when the screen is locked). I would have preferred that the LED on the device lights / the phone vibrate briefly and the information can be seen, such as in a text message.

Even now, many thanks for your help,

a small programmer who is still at the very beginning


Solution

  • You need to write a Service which runs in the background and set a ProximityAlert to trigger a Pending Intent when user enters your specific area.