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

前端 未结 10 1075
我寻月下人不归
我寻月下人不归 2020-12-01 01:35

I\'m having a weird issue that is causing a conflict. I had to switch to native Fragments to fix it, but there are bugs with that.

My original problem:

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 01:51

    Adding this to the parent activity works for me:

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        List fragments = getSupportFragmentManager().getFragments();
        if (fragments != null) {
            for (Fragment fragment : fragments) {
                fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
    }
    

    Source: https://code.google.com/p/android/issues/detail?id=189121#c5

提交回复
热议问题