0

I am trying to implement the new permissions model into my application. I am facing a weird issue. When I request with code i in a fragment, then onRequestPermissionResult of that fragment is not called, instead only the parent activity's onRequestPermissionResult is called with the same request code. This is causing unusual behaviour. I am using v4supportFragment. my min api is 14 and max is 23.

Note: This is not a nested fragment. Also, I have browsed this post of stackoverflow but it is not that helpful.

Request runtime permissions from v4.Fragment and have callback go to Fragment?

Community
  • 1
  • 1
Udit Khandelwal
  • 326
  • 3
  • 15

1 Answers1

5

Here's the line of code that I am using for requesting permission .ActivityCompat.requestPermissions(activity, permissionGroup, requestCode);

With this call, the result will go to activity. The fragment is not in the parameter list, and you are not calling a method on the fragment, and so the fragment is not involved.

Use FragmentCompat.requestPermissions() if you want the response to go to a native Fragment. Or, call requestPermissions() on a v4 Fragment to have the response go to that fragment.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491