Created
August 6, 2020 12:13
-
-
Save Dmuasya/88bace36a7ad94ba773ae3b292d99bb5 to your computer and use it in GitHub Desktop.
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
@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