Created
November 17, 2015 10:49
-
-
Save walteranyika/6108966f0dfcef4d6d53 to your computer and use it in GitHub Desktop.
Code To Get Location Updates For An App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
LocationListener listener=new LocationListener() { | |
@Override | |
public void onLocationChanged(Location location) { | |
double lat= location.getLatitude(); | |
double lon = location.getLongitude(); | |
double speed =location.getSpeed(); | |
//do something with this values | |
} | |
@Override | |
public void onStatusChanged(String provider, int status, Bundle extras) { | |
Log.d("DATA","STATUS CHANGED "+provider); | |
} | |
@Override | |
public void onProviderEnabled(String provider) { | |
Log.d("DATA","PROVIDER ENABLED "+provider); | |
} | |
@Override | |
public void onProviderDisabled(String provider) { | |
Log.d("DATA","PROVIDER DISENABLED "+provider); | |
} | |
}; | |
String provider=LocationManager.GPS_PROVIDER; | |
manager.requestLocationUpdates(provider,5000,5,listener); | |
}catch (SecurityException e) | |
{ | |
Log.e("DATA","Could Not Fetch The Location"); | |
} | |
//manager.removeUpdates(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment