if(dialog!=null && dialog.isShowing()) dialog.dismiss();//偶尔抛出异常 ---------------------------------------------------------------------------- java.lang.IllegalArgumentException: View not attached to window manager at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:356) at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:201) at android.view.Window$LocalWindowManager.removeView(Window.java:400) at android.app.Dialog.dismissDialog(Dialog.java:268) at android.app.Dialog.access$000(Dialog.java:69) at android.app.Dialog$1.run(Dialog.java:103) at android.app.Dialog.dismiss(Dialog.java:252) at xxx.onPostExecute(xxx$1.java:xxx) //----------------------------------------------------------------------// @Override protected void onPostExecute(MyResult result) { try { if ((this.mDialog != null) && this.mDialog.isShowing()) { this.mDialog.dismiss(); } } catch (final IllegalArgumentException e) { // Handle or log or ignore } catch (final Exception e) { // Handle or log or ignore } finally { this.mDialog = null; } }
Dialog在被dismiss的时候
I guess sometimes activity gets finished before dialog successfully dismisses.
ps:项目在登录的时候要处理的事情比较多。很多用户应该不想等待,把activity后台了。导致act被回收