Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try with the distance it works for you I think: <a href="http://developer.android.com/reference/android/location/Location.html#distanceBetween%28double,%20double,%20double,%20double,%20float%5B%5D%29" rel="nofollow noreferrer">distanceBetween</a></p> <p>Yo can implement your listener with a Runnable:</p> <pre><code> 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 &lt; ...) { //do something } handler.removeCallbacks(circleChecker); handler.postDelayed(circleChecker, circleCheckingDelay); } }; </code></pre> <p>Add the following functions in your mapActivity:</p> <p>OnResume:</p> <pre><code> handler.postDelayed(circleChecker, circleCheckingDelay); </code></pre> <p>OnPause:</p> <pre><code> handler.removeCallbacks(circleChecker); </code></pre> <p>Check this link too: <a href="https://stackoverflow.com/questions/5936912/how-to-find-the-distance-between-two-geopoints">how to find the distance between two geopoints?</a></p> <p>for example the function to get the distance:</p> <pre><code>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]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload