protected void loadWebViewData(String content) { if (Build.VERSION.SDK_INT < 18) { descriptionView.clearView(); } else { descriptionView.loadUrl("about:blank"); } // webview bug android versions 2.3.X // http://stackoverflow.com/a/8162828/1484047 if ("2.3".equals(Build.VERSION.RELEASE)) { descriptionView.loadDataWithBaseURL(null, content, "text/html; charset=utf-8", "utf-8", null); } else { myWebViewClient.setContent(content); descriptionView.loadUrl("file:///android_asset/integreat.html"); // descriptionView.loadData(content, "text/html; charset=utf-8", "utf-8"); } }
@Override public void onPageFinished(WebView view, String url) { String TAG = StaticBlob.TAG(); super.onPageFinished(view, url); if (!url.startsWith( "http://wufoo.com/")) // In this case the super's method is going to re-load the page to // trigger the JS handler return; // so we don't need to do anything. baconPDialog.hide(); String draft = PreferenceManager.getDefaultSharedPreferences(ContactForm.this) .getString("ContactDraft", null); Log.i(TAG, "Restoring draft."); if (draft != null) { String javascript = "javascript:"; String element = null, value = null; for (String s : draft.split("\\|")) { element = s.split("=")[0]; if (element.trim().length() == 0) continue; System.out.println("ContactForm:S: " + s); if (s.contains("=") && s.split("=").length == 2) { value = s.split("=")[1]; javascript = javascript.concat( "document.getElementById('" + element + "').value='" + value + "'; "); } else { javascript = javascript.concat("document.getElementById('" + element + "').checked='true'; "); } Log.i(TAG, element + " = " + value); } Log.i(TAG, javascript); view.loadUrl(javascript); PreferenceManager.getDefaultSharedPreferences(ContactForm.this) .edit() .remove("ContactDraft") .commit(); } Log.i(TAG, "Changing wvClient"); // view.setWebViewClient(new MyWebViewClient()); }