Clipboard API call throws NotAllowedError without invoking onPermissionRequest()

Clipboard API’s writeText method docs says, we need to obtain clipboard-write permission using Permissions API but navigator.permission is undefined in WebView, maybe because they don’t want to mix web permissions with Android OS permissions. There is one more way by which we can copy text to clipboard from Android WebView: by calling native Java method … Read more

Android – WebView language changes abruptly on Android 7.0 and above

Ted Hopp’s answer managed to solve the problem, but he didn’t address the question of why this occurs. The reason is the changes made to the WebView class and its support package in Android 7.0. Background: Android’s WebView is built using WebKit. While it was originally a part of AOSP, from KitKat onwards a decision … Read more

Disable scrolling in webview?

Here is my code for disabling all scrolling in webview: // disable scroll on touch webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return (event.getAction() == MotionEvent.ACTION_MOVE); } }); To only hide the scrollbars, but not disable scrolling: WebView.setVerticalScrollBarEnabled(false); WebView.setHorizontalScrollBarEnabled(false); or you can try using single column layout but this only works … Read more

How do I get the web page contents from a WebView?

I think I found the answer in this post on lexandera.com. The code below is basically a cut-and-paste from the site. It seems to do the trick. final Context myApp = this; /* An instance of this class will be registered as a JavaScript interface */ class MyJavaScriptInterface { @JavascriptInterface @SuppressWarnings(“unused”) public void processHTML(String html) … Read more

Loading existing .html file with android WebView

ok, that was my very stupid mistake. I post the answer here just in case someone has the same problem. The correct path for files stored in assets folder is file:///android_asset/* (with no “s” for assets folder which i was always thinking it must have a “s”). And, mWebView.loadUrl(“file:///android_asset/myfile.html”); works under all API levels. I … Read more

Android – Preventing WebView reload on Rotate

I think the main problem is that you call web.loadUrl(webURL); also when savedInstanceState != null EDIT Try: if (savedInstanceState == null) { web.loadUrl(webURL); } EDIT2: You also need the onSaveInstanceState and onRestoreInstanceState override. @Override protected void onSaveInstanceState(Bundle outState ) { super.onSaveInstanceState(outState); web.saveState(outState); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); web.restoreState(savedInstanceState); } Note: Please also … Read more

Is there a limit on length of the key (string) in JS object?

I have researched this a bit. MDN is silent on the issue, and so is the spec (ES5, ES6). They only state that the property accessor must be a string, without any qualifications – in other words, there is no limit as far as the spec is concerned. That’s hardly surprising. How browsers handle it, … Read more

Playing HTML5 video on fullscreen in android webview

Edit 2014/10: by popular demand I’m maintaining and moving this to GitHub. Please check cprcrack/VideoEnabledWebView for the last version. Will keep this answer only for reference. Edit 2014/01: improved example usage to include the nonVideoLayout, videoLayout, and videoLoading views, for those users requesting more example code for better understading. Edit 2013/12: some bug fixes related … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)