AndroidMob
AndroidMob

Reputation: 101

marshmallow permissions dialog ALLOW button not working why?

I have integrated marshmallow permissions dialog according to new material design, but permission dialog is working on emulator but not on real device. and also i am not getting any error. can any one please help me?

I am using below code:-

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

Upvotes: 3

Views: 2852

Answers (2)

Eric
Eric

Reputation: 17556

It is not a problem with your code....

I had the same problem and was able to fix it with the help of a similar stackoverflow post.

Solution

Force stopping this application will make the permission dialog allow buttons to work again.

Upvotes: 1

mitesh viradiya
mitesh viradiya

Reputation: 66

I do this what it may be useful to u

                    if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CALL_PHONE) && ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
                        showDialogOK("Phone State & Call Phone Services Permission required for this app",
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        switch (which) {
                                            case DialogInterface.BUTTON_POSITIVE:
                                                checkAndRequestPermissions();
                                                break;
                                            case DialogInterface.BUTTON_NEGATIVE:
                                                // proceed with logic by disabling the related features or quit the app.
                                                finish();
                                                break;
                                        }
                                    }
                                });
                    }

showDialog method and its work me for CALL_PHONE and READ_PHONE_STATE

private void showDialogOK(String message, DialogInterface.OnClickListener okListener) {
    new AlertDialog.Builder(this)
            .setMessage(message)
            .setPositiveButton("OK", okListener)
            .setNegativeButton("Cancel", okListener)
            .create()
            .show();
}

Upvotes: 1

Related Questions