DialogFragment崩溃 Can not perform

2019-02-19  本文已影响0人  周大侠侠侠侠侠侠侠侠侠侠侠侠侠
        //重写DialogFragment的show方法
        //可以查看showAllowingStateLoss不过被hide
        //通过反射拿到这两个变量进行设置
       try {
            val mDismissed = DialogFragment::class.java.getDeclaredField("mDismissed")
            mDismissed.isAccessible = true
            mDismissed.set(this, false)
            val mShownByMe = DialogFragment::class.java.getDeclaredField("mShownByMe")
            mShownByMe.isAccessible = true
            mShownByMe.set(this, true)
            manager.beginTransaction()
                    .add(this, tag)
                    .commitAllowingStateLoss()
            }
        } catch (e: Throwable) {
            LogUtils.eTag(TAG, e.toString())
        }
上一篇下一篇

猜你喜欢

热点阅读