PictureSelector 继承Activity 抛出找不到FragmentManager

u2nhd7ah  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(94)

Current use version?

当前使用的版本是多少?
v3.10.6

Will this problem occur in demo?

Demo能否复现这问题?
必现

Describe the problem or provide an error log?

描述问题或提供错误log?
就是目前我们自己写的类一般都是继承自AppCompatActivity或者FragmentActivity了,
但是我们现在项目上做混合开发,FlutterActivity继承自 Activity,这个时候抛出了异常

            FragmentManager fragmentManager = null;
            if (activity instanceof AppCompatActivity) {
                fragmentManager = ((AppCompatActivity) activity).getSupportFragmentManager();
            } else if (activity instanceof FragmentActivity) {
                fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
            } else {
                // 此处是不是可以兼容下 android.app.FragmentManager
            }
            if (fragmentManager == null) {
                throw new NullPointerException("FragmentManager cannot be null");
            }
            if (!(activity instanceof IBridgePictureBehavior)) {
                throw new NullPointerException("Use only camera openCamera mode," +
                        "Activity or Fragment interface needs to be implemented " + IBridgePictureBehavior.class);
            }
lxkprmvk

lxkprmvk1#

另外 代码是可以 少一个判断的 AppCompatActivity 继承自 FragmentActivity

yshpjwxd

yshpjwxd2#

我也遇到了,如果继承FlutterFragmentActivity,我们代码会有其他问题。能否兼容普通Activity呢

相关问题