Search code examples
androidandroid-permissionsandroid-6.0-marshmallow

How can I customize the permission dialog in Android?


Suppose I request a permission at runtime like the following:

ActivityCompat.requestPermissions(
    thisActivity,
    new String[]{Manifest.permission.READ_CONTACTS, MY_PERMISSIONS_REQUEST_READ_CONTACTS}
);

The Android system creates a popup dialog to request permission. How can I define a custom layout for that dialog?


Solution

  • The short answer is: you can't.

    As the Android documentation puts it:

    When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure or alter that dialog box. If you need to provide any information or explanation to the user, you should do that before you call requestPermissions(), as described in "Explain why the app needs permissions".

    In summary: There is no way to define a custom layout for the permission dialog for now.

    You can find more detailed information here: http://developer.android.com/training/permissions/requesting.html