2

I made a android application with multiple Geolocation on Google map (pins) I would like to send a notification when the user is close to one of these locations. Any ideas?

Kristijan Drača
  • 614
  • 4
  • 16

1 Answers1

3

This is actually fairly easy. First, set up an application that monitors your location. This post will show you more on that.

Once you know your position, you can simply determine if you're within a certain range of it. To calculate the distance between two points, try the Location class:

Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results);

results is a float[], so to return the distance, simply use float distance = results[0];.

So, in a nutshell, compile a list of waypoints you want to recognize. Then, in your GPS monitoring code, regularly check the distance between yourself and the list of points. If you're within a threshold, say 100m, then send a notification as a Toast message or something.

Good luck!

Community
  • 1
  • 1
crocboy
  • 2,887
  • 2
  • 22
  • 25