Skip to content Skip to sidebar Skip to footer

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:

public static int MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION =1;

then catch the result as:

    @Override
public void onRequestPermissionsResult(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"