我知道当我尝试在后台线程上显示ProgressDialog时抛出异常无法在未调用Looper.prepare()的线程内创建处理程序, 因为我们正在尝试从后台线程修改UI.但是当我们在后台线程中忽略该对话框时
因为我们正在尝试从后台线程修改UI.但是当我们在后台线程中忽略该对话框时,不会抛出任何异常.为什么我们在后台线程中关闭对话框时没有抛出异常,因为我们也是后台线程中的modifyng UI.
谢谢
这是Dialog的dismiss()方法的代码,显示了为什么没有抛出异常和dismiss的工作原理:/** * Dismiss this dialog, removing it from the screen. This method can be * invoked safely from any thread. Note that you should not override this * method to do cleanup when the dialog is dismissed, instead implement * that in {@link #onStop}. */ public void dismiss() { if (Thread.currentThread() != mUiThread) { mHandler.post(mDismissAction); } else { mDismissAction.run(); } }