0
我在TabView中有一個WebView。 webView有一個按鈕。當按下按鈕時,微調器打開。 我只是用URL加載webview。動作監聽器和微調器是從服務器端觸發的。在顯示對話框屏幕時TabView內部的Webview崩潰
webview = (WebView) findViewById(R.id.webview);
....
....
webview.loadUrl(locationUrl);
我的應用程序是在Android 2.2上開發的。它在OS 2.2的設備上工作正常,但在2.3中崩潰。
下面是日誌
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.ViewRoot.setView(ViewRoot.java:527)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.view.Window$LocalWindowManager.addView(Window.java:424)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.app.Dialog.show(Dialog.java:241)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.webkit.WebView$InvokeListBox.run(WebView.java:7583)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Handler.handleCallback(Handler.java:587)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Handler.dispatchMessage(Handler.java:92)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.os.Looper.loop(Looper.java:130)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at java.lang.reflect.Method.invoke(Method.java:507)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-24 13:44:24.878: ERROR/AndroidRuntime(2684): at dalvik.system.NativeStart.main(Native Method)
似乎你的背景超出了範圍。使用getApplictionContext()來顯示dailog – Arslan