Search code examples
androidpermissionsandroid-6.0-marshmallow

Android M permission dialog not showing


I'm currently trying to adapt my application to the new permissions model of Android M.

I'm collecting all the permissions I require, then run

Log.i("Permissions", "Requesting permissions: " + permissions);
requestPermissions(requiredPermissions.toArray(new String[requiredPermissions.size()]), requestCodeForPermissions);

requiredPermissions holds the permissions I need like android.permission.WRITE_EXTERNAL_STORAGE.

That routine is definitely executed as I have the Log line in the logcat:

08-07 12:52:46.469: I/Permissions(1674): Requesting permissions: android.permission.RECEIVE_BOOT_COMPLETED; android.permission.WRITE_EXTERNAL_STORAGE

But the permissions dialog never shows, let alone is onRequestPermissionsResult() called.

What am I doing wrong? Based on some tutorials I found I'm not missing anything. I only have the emulator for testing, no physical device. This is the about screen from settings: Image

It might be worth mentioning something else: If I try to open the overview of installed apps from the home screen I only get launcher3 has exited. I'm not sure if that might be related.

Does anybody have an idea why it's not showing?


Solution

  • Based on the comment from Hilal (thanks a lot!): In my case my app is indeed using tabhost and the permissions were requested from an Activity inside the tabhost. After starting a separate activity that requests the permissions it is working.