4

I am requesting permissions from my LocationFinder class, I am passing activity but I cannot override onRequestPermissionResult, I cannot find setOnRequestPermissionResultListener

How can it be done?

boolean requestLocPermession(Activity act,ActivityCompat actComp) {
    if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(act, Manifest.permission.READ_CONTACTS)) {

            // Show an expanation to the user *asynchronously* -- don't
            // block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.
            Toast.makeText(act, "shouldShowRequestPermissionRationale", Toast.LENGTH_LONG).show();
        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(act, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION },
                    MY_PERMISSIONS_REQUEST_READ_CONTACTS);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }

    }

    actComp.setOnRequestPermissionsRe??
}
124697
  • 22,097
  • 68
  • 188
  • 315

0 Answers0