My_permissions_request_access_fine_location Permission Android Not Recognised In Code
We are currently trying to request GPS permissions from an android phone so that we can show the current location on a Google Map. We have included this manifest, outside of applic
Solution 1:
you have to define it like:
publicstaticint MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION =1;
then catch the result as:
@OverridepublicvoidonRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION : {
// If request is cancelled, the result arrays are empty.if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the// contacts-related task you need to do.
} else {
// permission denied, boo! Disable the// functionality that depends on this permission.
}
return;
}
// other 'case' lines to check for other// permissions this app might request
}
}
Post a Comment for "My_permissions_request_access_fine_location Permission Android Not Recognised In Code"