try with the distance it works for you I think: distanceBetween
Yo can implement your listener with a Runnable:
private Handler handler = new Handler();
public static final int circleCheckingDelay = 1000; // in ms
private Runnable circleChecker = new Runnable()
{
public void run()
{
float distance= getDistance(GeoPoint p1, GeoPoint p2);
if(distance < ...)
{
//do something
}
handler.removeCallbacks(circleChecker);
handler.postDelayed(circleChecker, circleCheckingDelay);
}
};
Add the following functions in your mapActivity:
OnResume:
handler.postDelayed(circleChecker, circleCheckingDelay);
OnPause:
handler.removeCallbacks(circleChecker);
Check this link too:
how to find the distance between two geopoints?
for example the function to get the distance:
public float getDistance(GeoPoint p1, GeoPoint p2) {
double lat1 = ((double)p1.getLatitudeE6()) / 1e6;
double lng1 = ((double)p1.getLongitudeE6()) / 1e6;
double lat2 = ((double)p2.getLatitudeE6()) / 1e6;
double lng2 = ((double)p2.getLongitudeE6()) / 1e6;
float [] dist = new float[1];
Location.distanceBetween(lat1, lng1, lat2, lng2, dist);
return dist[0];
}