2011-05-17 31 views
1

我有一個問題,當設備方向改變了很多次, 此日誌:如何處理加速強制關閉在Android

05-17 11:28:53.121: ERROR/WindowManager(284): Activity com.korekapi.ipay.activity.Search has leaked window [email protected] 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 [email protected] 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.access$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) 

因此如何克服加速度計,爲了不重裝/在刷新方向改變

感謝提前

回答

0

這嚴格來說不是一個加速度計的問題。您的問題是,您在Search.java課程中顯示ProgressDialog(請參閱05-17 11:28:53.121: ERROR/WindowManager(284): at com.korekapi.ipay.activity.Search$SearchTask.onPreExecute(Search.java:124) ),並且在Android更改方向並且活動爲destroy時不會將其刪除。最簡單的解決方案是阻止Android在定位更改上參與活動:有關詳情,請參閱How to handle screen orientation change when progress dialog and background thread active?

更復雜的是清理自己身後的所有對話框:爲此,您需要跟蹤任何打開的對話框並自行關閉它們。