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

前端 未结 10 1103
我寻月下人不归
我寻月下人不归 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:55

    Just use requestPermission("your permission/s in string array",your request code) simply no need to use Fragment.requestPermissons(String[],int );

    This method in your fragment calls requestPermissions of android.support.v4.app.Fragment class i.e

    public final void requestPermissions(@NonNull String[] permissions, int requestCode) {
            if (mHost == null) {
                throw new IllegalStateException("Fragment " + this + " not attached to Activity");
            }
            mHost.onRequestPermissionsFromFragment(this, permissions, requestCode);
        }
    

提交回复
热议问题