Handling permission in Fragment
Hi, thanks for this awesome library. Can you please help me with handling the permission results in a Fragment? At the moment, the Activity intercept all results. Thanks
@saintjab Hi~ Can you tell me the way you use to apply the permission? (There are three ways in the library)
I am using the FcPermissionsB.Builder class like so.
mFcPermissionsB = new FcPermissionsB.Builder(getActivity()) .onGrantedListener(new OnPermissionsGrantedListener() { @Override public void onPermissionsGranted(int requestCode, List<String> perms) { //doing my thing here } }) .onDeniedListener(new OnPermissionsDeniedListener() { @Override public void onPermissionsDenied(int requestCode, List<String> perms) { //denied } }) .positiveBtn4ReqPer(android.R.string.ok) .negativeBtn4ReqPer(R.string.cancel) .positiveBtn4NeverAskAgain(R.string.setting) .negativeBtn4NeverAskAgain(R.string.cancel) .rationale4ReqPer(getString(R.string.sms_permit)) .rationale4NeverAskAgain(getString(R.string.sms_denied)) .requestCode(SMS_PERMISSION_REQUEST_ID) .build(); mFcPermissionsB.requestPermissions(Manifest.permission.SEND_SMS);
I am able to evoke the permission dialog but unable to get the results back in the fragment as parent Activity is taking over the results. The way around is I used event bus to publish and subscribe to the event so I can receive it at the fragment level. I don't know if you have a better way as I have some nested fragments in my activity. Thanks buddy.