友
onCreate()我正在使用Async线程从webservice加载数据。 当线程启动时,它会在屏幕上显示进度条并加载数据。
我遇到的一个突然问题是,当我开始显示活动进度条时,我改变了手机第二线程开始的方向&
应用程序崩溃。(Inovation Target Exception就是这样)。
这是log cat任何人指导我这个问题的解决方案是什么?
代码很简单
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchbanks);
threadBank = new AsyncBanks();
threadBank.execute("","");
}
04-29 16:08:26.811: ERROR/WindowManager(430): Activity com.FindMe.SearchBanks has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f64f98 that was originally added here
04-29 16:08:26.811: ERROR/WindowManager(430): android.view.WindowLeaked: Activity com.FindMe.SearchBanks has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f64f98 that was originally added here
04-29 16:08:26.811: ERROR/WindowManager(430): at android.view.ViewRoot.<init>(ViewRoot.java:247)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.view.Window$LocalWindowManager.addView(Window.java:424)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.Dialog.show(Dialog.java:241)
04-29 16:08:26.811: ERROR/WindowManager(430): at com.FindMe.SearchBanks$AsyncBanks.onPreExecute(SearchBanks.java:133)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.os.AsyncTask.execute(AsyncTask.java:391)
04-29 16:08:26.811: ERROR/WindowManager(430): at com.FindMe.SearchBanks.LoadRecords(SearchBanks.java:115)
04-29 16:08:26.811: ERROR/WindowManager(430): at com.FindMe.SearchBanks.onCreate(SearchBanks.java:76)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.os.Looper.loop(Looper.java:123)
04-29 16:08:26.811: ERROR/WindowManager(430): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-29 16:08:26.811: ERROR/WindowManager(430): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:08:26.811: ERROR/WindowManager(430): at java.lang.reflect.Method.invoke(Method.java:521)
04-29 16:08:26.811: ERROR/WindowManager(430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-29 16:08:26.811: ERROR/WindowManager(430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-29 16:08:26.811: ERROR/WindowManager(430): at dalvik.system.NativeStart.main(Native Method)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): java.lang.IllegalArgumentException: View not attached to window manager
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.view.Window$LocalWindowManager.removeView(Window.java:432)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.app.Dialog.dismissDialog(Dialog.java:278)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.app.Dialog.access$000(Dialog.java:71)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.app.Dialog$1.run(Dialog.java:111)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.app.Dialog.dismiss(Dialog.java:268)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at com.FindMe.SearchBanks$AsyncBanks.onPostExecute(SearchBanks.java:197)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at com.FindMe.SearchBanks$AsyncBanks.onPostExecute(SearchBanks.java:1)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.os.AsyncTask.finish(AsyncTask.java:417)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.os.Looper.loop(Looper.java:123)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at java.lang.reflect.Method.invoke(Method.java:521)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-29 16:08:28.652: ERROR/AndroidRuntime(430): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
即使您关闭对话框以便可以重新创建它,系统在销毁对话框和生命周期方法之间似乎存在竞争条件,您可以将其解除。我很少收到关于在配置更改时解除不存在的对话框的崩溃报告。
我建议捕获并忽略Dialog.dismiss()中的异常只是为了处理竞争条件。这就是我所做的,它解决了我的问题。
Steve @ WhitneyApps
答案 1 :(得分:0)