Get Javascript console when emulating WebView app

The answer you are referring to is for Android Browser app, not for WebView component. In order to get output from console.log() family of functions, you need to set a WebChromeClient for your WebView and override onConsoleMessage() (doc) method, like this: webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage consoleMessage) { android.util.Log.d(“WebView”, consoleMessage.message()); return true; } … Read more

WKWebView didn’t finish loading, when didFinishNavigation is called – Bug in WKWebView?

For those still looking for an answer to this, the marked answer is BS, he just forced his way into getting it accepted. Using property, “loading” and webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) both do the same thing, indicate if the main resource is loaded. Now, that does not mean the entire webpage/website is loaded, because … Read more

Destroy webview in Android

The WebView might not be destroyed because you are removing the view in the onDestroy(), which can be called in a few different occasions: when the user exits the app via the back button, when the user presses the home button and then swipes the app from recents, or when the system kills your app … Read more

webview shouldinterceptrequest example

Well, the short answer is that it works quite similar to shouldOverrideUrlLoading(WebView view, String url), as illustrated in the WebView tutorial. To get you started, see the code below. You simply override the shouldInterceptRequest(WebView view, String url) method of your WebViewClient. Obviously you don’t have to do that inline, but for the sake of compactness … Read more

inject CSS to a site with webview in android

You can’t inject CSS directly however you can use Javascript to manipulate page dom. public class MainActivity extends ActionBarActivity { WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = new WebView(this); setContentView(webView); // Enable Javascript webView.getSettings().setJavaScriptEnabled(true); // Add a WebViewClient webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { // Inject … Read more