看看這些作品的代碼:活動已泄漏的窗口 - Android電子
Custom views and window attributes on Android
問題
當我點擊 'Home鍵',exception
拋出:Activity
已泄漏窗口.. 。from this line:
localWindowManager.addView(colourView, layoutParams);
Questi (s)
你知道是什麼原因造成的嗎?
問題不會發生,當我用後退按鈕關閉應用程序。
異常/錯誤日誌
W/InputManagerService( 96): Starting input on non-focused client [email protected] (uid=10056 pid=1368)
D/CordovaActivity(1368): CordovaActivity.onDestroy()
D/CordovaWebView(1368): >>> loadUrlNow()
E/WindowManager(1368): Activity com.phonegap.helloworld.HelloWorld has leaked window [email protected] that was originally added here
E/WindowManager(1368): android.view.WindowLeaked: Activity com.phonegap.helloworld.HelloWorld has leaked window [email protected] that was originally added here
E/WindowManager(1368): at android.view.ViewRoot.<init>(ViewRoot.java:258)
E/WindowManager(1368): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
E/WindowManager(1368): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/WindowManager(1368): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/WindowManager(1368): at pl.edu.uj.tcs.student.xxx.Display.setColorsViews(Display.java:181)
E/WindowManager(1368): at pl.edu.uj.tcs.student.xxx.Display$3.run(Display.java:139)
E/WindowManager(1368): at android.os.Handler.handleCallback(Handler.java:587)
E/WindowManager(1368): at android.os.Handler.dispatchMessage(Handler.java:92)
E/WindowManager(1368): at android.os.Looper.loop(Looper.java:130)
E/WindowManager(1368): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/WindowManager(1368): at java.lang.reflect.Method.invokeNative(NativeMethod)
E/WindowManager(1368): at java.lang.reflect.Method.invoke(Method.java:507)
E/WindowManager(1368): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/WindowManager(1368): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/WindowManager(1368): at dalvik.system.NativeStart.main(Native Method)
D/CordovaActivity(1368): onMessage(onPageStarted,about:blank)
D/CordovaWebViewClient(1368): onPageFinished(about:blank)
D/CordovaActivity(1368): onMessage(onPageFinished,about:blank)
D/CordovaActivity(1368): onMessage(exit,null)
I/power ( 96): *** set_screen_state 0
編輯:
我怎樣才能在科爾多瓦活動添加東西的onPause()的onStop()等函數?
編輯2:
爲什麼是一個問題?因爲我創建的所有類都擴展了CordovaPlugin和小型輔助類。就這樣。我不能(我想)修改Activity類的主體。我所能做的就是通過調用cordova.getActivity()
函數來獲得它的參考。
請從logcat中附上完整的堆棧跟蹤。 – ntv1000
附帶Stacktrace。 – tomwesolowski