0

我有一段代码在活动中显示进度对话框。

m_oProgressDialog = ProgressDialog.show(MyActivity.this, "", "");

但我在这一行反击崩溃,其错误日志如下.. android.view.WindowManager$BadTokenException: Unable to add window -- token

android.os.BinderProxy@419743f8 is not valid; is your activity running?
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:517)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
    at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
    at android.view.Window$LocalWindowManager.addView(Window.java:537)
    at android.app.Dialog.show(Dialog.java:289)

如果 MyActivity.this 和 getBaseContext() 任何人,我什至尝试了这个?

i have a function which shows a progress dialog... i first check whether its showing or not ...if not i will show..

 private void showProgressDialog()
    {
        if( (m_oProgressDialog!=null) && (!this.isFinishing()) )
        {
            if( m_oProgressDialog.isShowing() == false )
                m_oProgressDialog.show();
        }
        else
        {
            m_oProgressDialog = ProgressDialog.show(MyActivity.this, "", "");
        }
 }
4

0 回答 0