开发者

how to handle accelerometer force close on android

I have a problem when the device orientation changed many times, this the log :

05-17 11:28:53.121: ERROR/WindowManager(284): Activity com.korekapi.ipay.activity.Search has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43851260 that was originally added here
05-17 11:28:53.121: ERROR/WindowManager(284): android.view.WindowLeaked: Activity com.korekapi.ipay.activity.Search has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43851260 that was originally added here
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.view.ViewRoot.<init>(ViewRoot.java:214)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.view.Window$LocalWindowManager.addView(Window.java:409)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.Dialog.show(Dialog.java:238)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ProgressDialog.show(ProgressDialog.java:107)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ProgressDialog.show(ProgressDialog.java:90)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ProgressDialog.show(ProgressDialog.java:85)
05-17 11:28:53.121: ERROR/WindowManager(284):     at com.korekapi.ipay.activity.Search$SearchTask.onPreExecute(Search.java:124)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.os.AsyncTask.execute(AsyncTask.java:391)
05-17 11:28:53.121: ERROR/WindowManager(284):     at com.korekapi.ipay.activity.Search.doSearch(Search.java:101)
05-17 11:28:53.121: ERROR/WindowManager(284):     at com.korekapi.ipay.activity.Search.onCreate(Search.java:70)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3502)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread.a开发者_如何转开发ccess$2200(ActivityThread.java:116)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1798)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.os.Looper.loop(Looper.java:123)
05-17 11:28:53.121: ERROR/WindowManager(284):     at android.app.ActivityThread.main(ActivityThread.java:4203)
05-17 11:28:53.121: ERROR/WindowManager(284):     at java.lang.reflect.Method.invokeNative(Native Method)
05-17 11:28:53.121: ERROR/WindowManager(284):     at java.lang.reflect.Method.invoke(Method.java:521)
05-17 11:28:53.121: ERROR/WindowManager(284):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-17 11:28:53.121: ERROR/WindowManager(284):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
05-17 11:28:53.121: ERROR/WindowManager(284):     at dalvik.system.NativeStart.main(Native Method)

so how to overcome the accelerometer in order not to reload / refresh during the orientation change

thanks for advance


This is strictly speaking not an accelerometer problem. Your issue is that you are showing a ProgressDialog in your Search.java class (see 05-17 11:28:53.121: ERROR/WindowManager(284): at com.korekapi.ipay.activity.Search$SearchTask.onPreExecute(Search.java:124) ) and not removing it when the orientation is changed and the Activity is destroyed by Android. The easiest solution is to prevent Android from destroying the Activity on orientation changes: see How to handle screen orientation change when progress dialog and background thread active? for more on this.

More complex is to clean up behind yourself and close all Dialogs: for this you will need to track any open dialogs and close them yourself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜