Karumi/Dexter

Showing a dialog before android permision dialog onPermissionRationaleShouldBeShown does not work when pressing back button

Aperta

#213 aperta il 22 lug 2018

 (2 commenti) (2 reazioni) (0 assegnatari)Java (682 fork)batch import
help wanted

Metriche repository

Star
 (5224 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Expected behaviour

I want to help the user understand why my app needs a permission before showing android permission dialog. I'm using a helper dialog to explain that. I disabled the back press button on the helper dialog so the only way to close the dialog is to press a button on the dialog. after user press the close button I consume token with token.continuePermissionRequest(); and android permission dialog is shown and everything should continue to be working fine.

Actual behaviour

when a helper dialog is displayed to user to explain why permission needed and user press on back button then clicks on dialog close button dexter does not work anymore anywhere and show nothing.

Steps to reproduce

  1. after the helper dialog is shown just press back button then continue.
@Override
    public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token)
    {
        new AlertDialog.Builder(context).setTitle("test")
                .setMessage("test")
                .setCancelable(false)
                .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        token.continuePermissionRequest();
                    }
                })
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        token.continuePermissionRequest();
                    }
                })
                .setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override public void onDismiss(DialogInterface dialog) {
                        token.continuePermissionRequest();
                    }
                })
                .show();

    }
`

  

Dexter.withActivity(this)
                .withPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .withListener(dialogPermissionListener)
                .check();

Version of the library

5.0.0

Guida contributor