On showing dialog i get “Can not perform this action after onSaveInstanceState”

前端 未结 17 1071
甜味超标
甜味超标 2020-11-29 18:37

Some users are reporting, if they use the quick action in the notification bar, they are getting a force close.

I show a quick action in the notification who calls t

17条回答
  •  庸人自扰
    2020-11-29 19:26

    After few days I want share my solution how I've fixed it, to show DialogFragment you should to override show() method of it and call commitAllowingStateLoss() on Transaction object. Here is example in Kotlin:

    override fun show(manager: FragmentManager?, tag: String?) {
            try {
                val ft = manager?.beginTransaction()
                ft?.add(this, tag)
                ft?.commitAllowingStateLoss()
            } catch (ignored: IllegalStateException) {
    
            }
    
        }
    

提交回复
热议问题