Android gps : how to check if a certain point has been reached? <p>I am working on an Android app and I need to make sure that the device has reached a certain point described with lat and lon. The only thing that I can think of is to have something like that :</p> <pre><code> Location initLoc = theManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); double lat = initLoc.getLatitude(); double lon = initLoc.getLongitude(); MyPoint firstPoint = getPoints().get(0); double dist = CalcHelper.getDistance1(lat, lat, firstPoint.getLat(), firstPoint.getLon()); while(dist &gt; 30){ initLoc = theManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); lat = initLoc.getLatitude(); lon = initLoc.getLongitude(); dist = CalcHelper.getDistance1(lat, lon, firstPoint.getLat(), firstPoint.getLon()); } </code></pre> <p>But that causes the program to crash. I would be very appreciative if you could lead me to the right direction here.</p> <p>Let me take the opportunity to ask a further question. As I said I am new to Android and GPS and having in mind there is little documentation and information on how to properly develop applications that work with GPS I am working in blind basically. So my question is:</p> <p>This is how the onLocationChanged method looks like:</p> <pre><code> public void onLocationChanged(Location location) { double lat = location.getLatitude(); double lon = location.getLongitude(); MyPoint firstPoint = MainScreen.dataset.getPoints().get(0); double dist = CalcHelper.getDistance1(lat, firstPoint.getLat(),lon, firstPoint.getLon()); if(dist &lt; 10){ Context context = getApplicationContext(); CharSequence text = "Start reached. Starting moving on track"; int duration = 6000; Toast toast = Toast.makeText(context, text, duration); toast.show(); }else{ Context context = getApplicationContext(); CharSequence text = "Distance until start: "+dist; int duration = 6000; Toast toast = Toast.makeText(context, text, duration); toast.show(); } } </code></pre> <p>What I am trying to do is to make the program determine when I have reached the start of a track I have supplied as a set of points. So, when I start the program I receive a reasonable estimate on the distance. The problem is, when I start moving, the distance does not seem to be updated, it gets updated but after moving 50meters, it says i have only moved 5 say. On the other hand, when I start the application and I am less than 10m away from the starting point, it detects it properly. So basically, while I am moving with the device, the onLocationChanged method does not seem to give me the correct location that I am now on. Can you tell me what I might be doing wrong ? </p>