Separate cookie jar per WebView in OS X

The problem is there are no JS level cookie isolation. document.cookie still point to the shared cookie jar. To implement a true cookie isolated webview, you must override the cookie property of document. You may try my implementation: http://cyyuen.github.io/ADCookieIsolatedWebView It works for the site using document.cookie to get the cookie such as Dropbox.com. However, the … Read more

How to stop youtube video playing in Android webview?

See the following post about WebView threads never stopping Essentially you’ll need to call the WebView’s onPause method from your own Activity’s onPause method. The only trick with this is that you cannot call the WebView’s onPause method directly because it is hidden. Therefore you will need to call it indirectly via reflection. The following … Read more

Android WebView progress bar

For a horizontal progress bar, you first need to define your progress bar and link it with your XML file like this, in the onCreate: final TextView txtview = (TextView)findViewById(R.id.tV1); final ProgressBar pbar = (ProgressBar) findViewById(R.id.pB1); Then, you may use onProgressChanged Method in your WebChromeClient: MyView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { … Read more

How to load html string in a webview?

To load your data in WebView. Call loadData() method of WebView wv.loadData(yourData, “text/html”, “UTF-8″); You can check this example http://developer.android.com/reference/android/webkit/WebView.html [Edit 1] You should add — \ — before — ” — for example –> name=\”spanish press\” below string worked for me String webData = “<!DOCTYPE html><head> <meta http-equiv=\”Content-Type\” ” + “content=\”text/html; charset=utf-8\”> <html><head><meta http-equiv=\”content-type\” … Read more

Are WebViewClient and WebChromeClient mutually exclusive?

You certainly can use both, they just have different functions. Setting your own custom WebViewClient lets you handle onPageFinished, shouldOverrideUrlLoading, etc., WebChromeClient lets you handle Javascript’s alert() and other functions. Just make your own class, for example: public class MyWebChromeClient extends WebChromeClient { //Handle javascript alerts: @Override public boolean onJsAlert(WebView view, String url, String message, … Read more

WebView load website when online, load local file when offline

That sounds like a simple webview caching mechanism to me. The following should do what you are looking for: WebView webView = new WebView( context ); webView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB webView.getSettings().setAppCachePath( getApplicationContext().getCacheDir().getAbsolutePath() ); webView.getSettings().setAllowFileAccess( true ); webView.getSettings().setAppCacheEnabled( true ); webView.getSettings().setJavaScriptEnabled( true ); webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT ); // load online by default … Read more

How to set the initial zoom/width for a webview

The following code loads the desktop version of the Google homepage fully zoomed out to fit within the webview for me in Android 2.2 on an 854×480 pixel screen. When I reorient the device and it reloads in portrait or landscape, the page width fits entirely within the view each time. BrowserLayout.xml: <?xml version=”1.0″ encoding=”utf-8″?> … Read more

Android WebView with garbled UTF-8 characters.

You can try to edit the settings of your webview before you load the data: WebSettings settings = mWebView.getSettings(); settings.setDefaultTextEncodingName(“utf-8”); Also, as provided in the comment below, be sure to add “charset=utf-8” to the loadData call: mWebView.loadData(getString(R.string.info_texto), “text/html; charset=utf-8”, “utf-8”);

What do setUseWideViewPort() and setLoadWithOverviewMode() precisely do?

Apparently: setLoadWithOverviewMode(true) loads the WebView completely zoomed out setUseWideViewPort(true) makes the Webview have a normal viewport (such as a normal desktop browser), while when false the webview will have a viewport constrained to its own dimensions (so if the webview is 50px*50px the viewport will be the same size)