如何从与活动

时间:2016-02-18 10:36:58

标签: android

我正在从我的LocationFinder类请求权限,我正在传递活动但是我无法覆盖onRequestPermissionResult,我找不到setOnRequestPermissionResultListener

怎么做?

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??
}

0 个答案:

没有答案