0

On Android, if you revoke permission 2 times (I guess), the app cannot ever ask you again.

https://stackoverflow.com/a/36270554/10116440 tells to do this to check for permission:

if (ContextCompat.checkSelfPermission(getActivity(),
        Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {

    ActivityCompat.requestPermissions(getActivity(),
            new String[]{Manifest.permission.RECORD_AUDIO},
            REQUEST_MICROPHONE);

}

I can only compare to PackageManager.PERMISSION_DENIED and PackageManager.PERMISSION_GRANTED. How do I know that, if I call ActivityCompat.requestPermissions, it will show the microphone permission popup?

I'd like to show a button for the user to go to the permission on the settings in case there's no more possibility to show the popup.

Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • You need to read more about it, check the official documentation [Request app permissions](https://developer.android.com/training/permissions/requesting), furthermore, you can check [this medium article](https://link.medium.com/erheWZjG5eb). – Lalit Fauzdar Apr 01 '21 at 03:19

1 Answers1

1

You can use this library for permissions . Example code :

Dexter.withContext(this)
    .withPermission(Manifest.permission.CAMERA)
    .withListener(new PermissionListener() {
        @Override public void onPermissionGranted(PermissionGrantedResponse response) {/* ... */}
        @Override public void onPermissionDenied(PermissionDeniedResponse response) {/* ... */}
        @Override public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {/* ... */}
    }).check();

https://github.com/Karumi/Dexter

Yasin Ege
  • 605
  • 4
  • 14