Skip to content

Instantly share code, notes, and snippets.

@SlavaFir
Created March 26, 2019 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SlavaFir/20298c6eb3668d6c3c8ab5f691e1f3d9 to your computer and use it in GitHub Desktop.
Save SlavaFir/20298c6eb3668d6c3c8ab5f691e1f3d9 to your computer and use it in GitHub Desktop.
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
doSomethingWithLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment