onRequestPermissionsResult not being called in dialog fragment
This issue seems to be fixed in Android Support Library 23.3.0 and above versions.
If you’re using Support v4 Fragments, nested fragments will now receive callbacks to onRequestPermissionsResult().
Edit: @AndrewS, here's how you can update.
In your build.gradle(app) file, change the following line to use the latest support library 24.0.0 which is the latest version:
dependencies {
compile 'com.android.support:appcompat-v7:24.0.0'
}
There appears to be a bug in Android, where nested fragments do not support the onRequestPermissionsResult()
callback. For a DialogFragment
, a workaround appears to be to have the fragment wanting to show the dialog call a method on the hosting activity, and the activity shows the DialogFragment
itself.
If you're inside a Fragment
from support library, call requestPermissions()
directly, and your Fragment's onRequestPermissionsResult()
will be called back.
If you call ActivityCompat.requestPermissions()
, then it's the Activity
's onRequestPermissionsResult()
that will be called back.