调用父 activity 的 onRequestPermissionResult 而不是片段

onRequestPermissionResult of the parent activity is called instead of the fragment

我正在尝试在我的应用程序中实施新的权限模型。我面临一个奇怪的问题。当我在片段中使用代码 i 请求时,不会调用该片段的 onRequestPermissionResult,而只会使用相同的请求代码调用父级 activity 的 onRequestPermissionResult。这导致异常行为。我正在使用 v4supportFragment。我的最小值 api 是 14,最大值是 23。

注意:这不是嵌套片段。另外,我浏览了这个 post 的 Whosebug,但它没有那么有用。

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

通过此调用,结果将转到 activity。该片段不在参数列表中,您没有调用该片段的方法,因此不涉及该片段。

Use FragmentCompat.requestPermissions() if you want the response to go to a native Fragment. Or, call requestPermissions() on a v4 Fragment 让响应转到该片段。