Created
April 2, 2019 08:19
-
-
Save walteranyika/ec4179828b110db9e80f6f3db2d0cf08 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static final int PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION=2000; | |
boolean mLocationPermissionGranted=false; | |
private void getLocationPermission() { | |
if (ContextCompat.checkSelfPermission(getActivity(), | |
android.Manifest.permission.ACCESS_FINE_LOCATION) | |
== PackageManager.PERMISSION_GRANTED) { | |
mLocationPermissionGranted = true; | |
} else { | |
ActivityCompat.requestPermissions(getActivity(), | |
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, | |
PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION); | |
} | |
} | |
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { | |
mLocationPermissionGranted = false; | |
switch (requestCode) { | |
case PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION: { | |
// If request is cancelled, the result arrays are empty. | |
if (grantResults.length > 0 | |
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
mLocationPermissionGranted = true; | |
//getDeviceLocation(); | |
} | |
} | |
} | |
// updateLocationUI(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment