Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 1.07 KB  |  hits: 4  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. android:I can not stop GPS update
  2. LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  3. LocationListener locationlistenerforGPS = new mylocationlistenerGPS();
  4. lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationlistenerforGPS);
  5.        
  6. private class mylocationlistenerGPS implements LocationListener {
  7.   @Override
  8.   public void onLocationChanged(Location location) {
  9.       counterGPS++;
  10.       if (location != null) {
  11.       Log.d("LOCATION CHANGED", location.getLatitude() + " ");
  12.       Log.d("LOCATION CHANGED", location.getLongitude() + " ");
  13.       Toast.makeText(LocationActivity.this,"latitude: "+
  14.           location.getLatitude() + "longitude: " + location.getLongitude()
  15.           + " Provider:" + location.getProvider() + " Accuracy:" + location.getAccuracy(),
  16.           Toast.LENGTH_LONG).show();
  17.       }
  18.  
  19.   }
  20.   @Override
  21.   public void onProviderDisabled(String provider) {
  22.   }
  23.   @Override
  24.   public void onProviderEnabled(String provider) {
  25.   }
  26.   @Override
  27.   public void onStatusChanged(String provider, int status, Bundle extras) {
  28.   }
  29.   }