Android : BadTokenException when I want to show a progresssDialog a second time

為{幸葍}努か 提交于 2019-12-06 04:57:31

As what the error message told you, it's because you try to show a dialog in a Activity but the Activity is not running(have already been finished?). So before you show a dialog, you may want to make sure that the Activity is not finished:

public class MyActivity extends Activity {

    public void showDialog(Dialog dialog) {
        if (!isFinishing()) {
            // If activity is not finished, then show this dialog.
            dialog.show();
        }
    }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!