开发者

Dialog won't show. UI Threading issue

开发者 https://www.devze.com 2023-02-11 06:32 出处:网络
I have an inner class that is instantiated inside of a async callback. I would like a display a dialog when the callback completes, so I pass a handler to the inner class when the async operation is c

I have an inner class that is instantiated inside of a async callback. I would like a display a dialog when the callback completes, so I pass a handler to the inner class when the async operation is called, however, I'm getting:

 02-19 15:33:49.152: ERROR/AndroidRuntime(635): Uncaught handler: thread main exiting due to uncaught exception
    02-19 15:33:49.272: ERROR/AndroidRuntime(635): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@4322fef0 is not valid; is your activity running?
    02-19 15:33:49.272: ERROR/AndroidRuntime(635):     at android.view.ViewRoot.setView(ViewRoot.java:456)
    02-19 15:33:49.272: ERROR/AndroidRuntime(635):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
    02-19 15:33:49.272: ERROR/AndroidRuntime(635):     at android.view.Window开发者_JAVA百科ManagerImpl.addView(WindowManagerImpl.java:91)
    02-19 15:33:49.272: ERROR/AndroidRuntime(635):     at android.view.Window$LocalWindowManager.addView(Window.java:409)
    02-19 15:33:49.272: ERROR/AndroidRuntime(635):     at android.app.Dialog.show(Dialog.java:238)


This might be relevant to your case: http://dimitar.me/android-displaying-dialogs-from-background-threads/

0

精彩评论

暂无评论...
验证码 换一张
取 消