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

前端 未结 17 1068
甜味超标
甜味超标 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:31

    Make your dialog fragment object global and call dismissAllowingStateLoss() in onPause() method

    @Override
    protected void onPause() {
        super.onPause();
    
        if (dialogFragment != null) {
            dialogFragment.dismissAllowingStateLoss();
        }
    }
    

    Don't forget to assign value in fragment and call show() on button click or where ever.

提交回复
热议问题