need to call the superclass here to be fixed ( super.onRequestPermissionsResult() )

75 Views Asked by At

need to fix contact request permission for book for someone else feature on the app:

@Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
        switch (requestCode) {
            case Utils.REQUEST_READ_CONTACTS: {

                if (grantResults.length > 0
                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                    showContacts();

                } else {

                    // permission denied,Disable the
                    // functionality that depends on this permission.
                }
                return;
            }

        }

Overriding method should call super.onRequestPermissionsResult how can do this ?

I need to explain me how can fix this in android studio?

1

There are 1 best solutions below

0
Usman Mahmood On

you have to call super.onRequestPermissionResult like this :

@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults)
{
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    switch(requestCode) {
        case Utils . REQUEST_READ_CONTACTS : {

            if (grantResults.length > 0
                && grantResults[0] == PackageManager.PERMISSION_GRANTED
            ) {

                showContacts();

            } else {

                // permission denied,Disable the
                // functionality that depends on this permission.
            }
            return;
        }

    }
}