Android – how to intercept a form POST in android WebViewClient on API level 4

This is known issue, that shouldOverrideUrlLoading don’t catch POST. See http://code.google.com/p/android/issues/detail?id=9122 for details. Use GET! I personally tried using POST, because I expected some limitation of GET parameters (i.e. length of URL), but I just successfully passed 32000 bytes through GET locally without any problems.

shouldOverrideUrlLoading in WebView for Android not running

After some research I conclude that despite what most of the tutorials out there say, shouldOverrideUrlLoading() does not get called when: You load a URL like loadUrl(“http://www.google.com”); The browser redirects the user automatically via an HTTP Redirect. (See the comment from @hmac below regarding redirects) It does however, get called when you you click on … Read more

Android – Open target _blank links in WebView with external browser

After visiting the above links, I come up with this code and hope this helps. wv.getSettings().setSupportMultipleWindows(true); wv.setWebChromeClient(new WebChromeClient() { @Override public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg) { WebView.HitTestResult result = view.getHitTestResult(); String data = result.getExtra(); Context context = view.getContext(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data)); context.startActivity(browserIntent); return false; } });

Android 4.4 giving ERR_CACHE_MISS error in onReceivedError for WebView back

This error actually stems from outside of your application in most cases (occasionally it’s just a missing INTERNET permission, but that doesn’t sound like the case here). I was typing out an explanation, but found a much more straightforward example that doubles as an explanation in this answer to another question. Here’s the relevant bits, … Read more

Enabling general JavaScript in WebViewClient

I don’t know what your exact problem is, but i can enable the JavaScript and a custom WebViewclient without any problem: WebView vistaWeb = (WebView) findViewById(R.id.webview); vistaWeb.setWebChromeClient(new MyCustomChromeClient(this)); vistaWeb.setWebViewClient(new MyCustomWebViewClient(this)); vistaWeb.clearCache(true); vistaWeb.clearHistory(); vistaWeb.getSettings().setJavaScriptEnabled(true); vistaWeb.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

Android WebView for Facebook Like Button

To get past the blank page you do this: webview.setWebViewClient(new LikeWebviewClient(this)); private class LikeWebviewClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { Log.d(TAG, “onPageFinished url: ” +url); // Facebook redirects to this url once a user has logged in, this is a blank page so we override this // http://www.facebook.com/connect/connect_to_external_page_widget_loggedin.php?………… if(url.startsWith(“http://www.facebook.com/connect/connect_to_external_page_widget_loggedin.php”)){ String … Read more

What’s the difference between setWebViewClient vs. setWebChromeClient?

From the source code: // Instance of WebViewClient that is the client callback. private volatile WebViewClient mWebViewClient; // Instance of WebChromeClient for handling all chrome functions. private volatile WebChromeClient mWebChromeClient; // SOME OTHER SUTFFF……. /** * Set the WebViewClient. * @param client An implementation of WebViewClient. */ public void setWebViewClient(WebViewClient client) { mWebViewClient = client; … Read more