リスト内の項目をクリックするとjavascriptが挿入されたwebviewが表示されるアプリケーションがあります。ユーザーが同じ項目を再び押すと、webviewオブジェクトが保存されます。再読み込みとjavascriptの再注入の代わりに表示されます。アプリケーションクラス内のwebviewのArraylistにwebviewオブジェクトを保存することができました。選択ボックスまたは任意のダイアログでWebviewがクラッシュする
アイテムがArraylistに既に存在するかどうかをチェックし、存在する場合は対応するオブジェクトを取得し、そのオブジェクトを以下に示すようにアクティビティのコンテンツとして設定します。
temp_WebView=new WebView(this);
temp_WebView=(WebView)application.getWebview(j);
ViewGroup parent = (ViewGroup) application.getWebview(j).getParent();
parent.removeView(application.getWebview(j));
setContentView(temp_WebView);
This works fine but when clicking on any of the select box inside the webview where a dialog is populated it gets crashed with the following error,
WARN/WindowManager(60): Attempted to add application window with unknown token HistoryRecord{4506d1e8 tabviewapp.com/.Webresults}. Aborting.
DEBUG/AndroidRuntime(500): Shutting down VM
WARN/dalvikvm(500): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
ERROR/AndroidRuntime(500): FATAL EXCEPTION: main
ERROR/AndroidRuntime(500): android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running?
ERROR/AndroidRuntime(500): at android.view.ViewRoot.setView(ViewRoot.java:505)
ERROR/AndroidRuntime(500): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
ERROR/AndroidRuntime(500): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
ERROR/AndroidRuntime(500): at android.view.Window$LocalWindowManager.addView(Window.java:424)
ERROR/AndroidRuntime(500): at android.app.Dialog.show(Dialog.java:241)
ERROR/AndroidRuntime(500): at android.webkit.WebView$InvokeListBox.run(WebView.java:7095)
ERROR/AndroidRuntime(500): at android.os.Handler.handleCallback(Handler.java:587)
ERROR/AndroidRuntime(500): at android.os.Handler.dispatchMessage(Handler.java:92)
ERROR/AndroidRuntime(500): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(500): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(500): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(500): at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(500): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(500): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(500): at dalvik.system.NativeStart.main(Native Method)
WARN/ActivityManager(60): Force finishing activity tabviewapp.com/.Webresults
私はこの問題は、既存のオブジェクトのコンテキストを設定したり、WebViewの内部で生成されたダイアログにコンテキストを渡す方法を見つけ出すことができるのWebViewの文脈であるが、ないと思います。
ありがとうございます。