Skip to content

Instantly share code, notes, and snippets.

@100rabhkr
Created August 4, 2018 05:56
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 100rabhkr/3dad59a9b642482faf4ab6d34ada0cb7 to your computer and use it in GitHub Desktop.
Save 100rabhkr/3dad59a9b642482faf4ab6d34ada0cb7 to your computer and use it in GitHub Desktop.
LocationManager locationManager = (LocationManager) getActivity().getSystemService(LOCATION_SERVICE);
//Get current location to start with
Location myLocation = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
currentLatitude = myLocation.getLatitude();
currentLongitude = myLocation.getLongitude();
// Request location update using LocationManager.NETWORK_PROVIDER
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, MapFragment.this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment