Skip to content

Instantly share code, notes, and snippets.

@Dmuasya
Created August 6, 2020 12:13
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 Dmuasya/88bace36a7ad94ba773ae3b292d99bb5 to your computer and use it in GitHub Desktop.
Save Dmuasya/88bace36a7ad94ba773ae3b292d99bb5 to your computer and use it in GitHub Desktop.
@Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(120000); // two minute interval
mLocationRequest.setFastestInterval(120000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
//Location Permission already granted
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback,
Looper.myLooper());
mGoogleMap.setMyLocationEnabled(true);
} else {
//Request Location Permission
checkLocationPermission();
}
} else {
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback,
Looper.myLooper());
mGoogleMap.setMyLocationEnabled(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment