Questions tagged [android-webview]

Part of the Android API. A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity.

A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

Apart loading from the web, this component supports loading from assets (location file:///android_asset/, this folder must be called "assets" and be present in the project root) or other arbitrary folder. It also supports JavaScript but it is disabled by default and must be explicitly turned on.

Documentation for WebView.

7082 questions
66
votes
5 answers

How to clear cookies and cache of webview on Android when not in webview?

Upon a user's sign out from my app I am clearing everything that may have been cached previously from the webview by calling this method: public void clearCookiesAndCache(Context context){ CookieSyncManager.createInstance(context); …
JohnRock
  • 6,475
  • 12
  • 50
  • 61
65
votes
9 answers

How can I know that my WebView is loaded 100%?

I'm trying to load in my WebView some HTML code that contains JavaScript. Now , I want to test if my WebView is loaded before 5 secondes. I've tried the method getProgress(), but sometimes I get that the progress is 100, but my Webview is not…
Houcine
  • 22,593
  • 13
  • 53
  • 83
65
votes
1 answer

Clipboard API call throws NotAllowedError without invoking onPermissionRequest()

I have a simple page with a button, that when pressed, uses the Async Clipboard API to write to the clipboard. function testClipboard() { …
cyqsimon
  • 1,466
  • 10
  • 27
65
votes
8 answers

enable/disable zoom in Android WebView

There are some methods in WebSettings related to zoom: WebSettings.setSupportZoom WebSettings.setBuiltInZoomControls I noticed they work differently on some devices. For example, on my Galaxy S pinch to zoom is enabled by default, but on LG P500…
Evgeny Nacu
  • 1,573
  • 2
  • 12
  • 20
65
votes
8 answers

Webview avoid security alert from google play upon implementation of onReceivedSslError

I have a link which will open in webview. The problem is it cannot be open until I override onReceivedSslError like this: @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { …
65
votes
4 answers

Android - extracting cookies after login in webview

I have an application that opens a url in a webview, the user must then login to a site through the webview and receives a cookie once logged in. I'm having problems getting cookies after login. The problem is, I can achieve this using…
elgoog
  • 901
  • 1
  • 9
  • 20
64
votes
7 answers

Intercept and override HTTP requests from WebView

I have a WebView in my application in which some site is opened (always the same, it is my own page). The site has some JS code that loads some images from the remote host. I want to intercept requests to such images (by URL pattern) and give back…
Olegas
  • 9,749
  • 7
  • 46
  • 70
63
votes
6 answers

How does evaluateJavascript work?

I'm trying to use the new evaluateJavascript method in Android 4.4, but all I ever get back is a null result: webView1.evaluateJavascript("return \"test\";", new ValueCallback() { @Override public void onReceiveValue(String s) { …
CodingIntrigue
  • 65,670
  • 26
  • 159
  • 166
63
votes
4 answers

How to load html string in a webview?

i have a html string containing this:
NullPointerException
  • 32,153
  • 66
  • 194
  • 346
61
votes
2 answers

Android WebView leaves space for scrollbar

In my WebView, I have some block elements that have a background color (different than white). However, the background color does not go all the way across the sky.. um, screen. Instead, it leaves a small white strip to the right, for where the…
Felix
  • 84,032
  • 41
  • 145
  • 163
58
votes
11 answers

Android - local image in webview

I'm trying to diplay a local image in my webview : String data = "" + ""; webview.loadData(data, "text/html", "UTF-8"); This code doesn't display anything, instead of : …
Stéphane Piette
  • 5,123
  • 6
  • 32
  • 49
56
votes
8 answers

Add a Progress Bar in WebView

I am trying to add a progress/loading bar to my application that uses WebView. I am confused on how to implement a progress bar that appears every time a link is clicked. Current code: public class CULearnBrowser extends Activity { WebView…
Sean
  • 807
  • 1
  • 11
  • 20
53
votes
4 answers

android: webview inside dialog or popup

how to add web view inside dialog or popup window. my web view hold URL WebView.loadurl() .when view added inside dialog it still moving to the browser. I've been in android loading webview in dialog but is no example of how to do it? thanks
roy.d
  • 983
  • 2
  • 14
  • 32
51
votes
11 answers

Android WebView not loading URL

I want to load the URL in WebView I have used the following Code: webView = (WebView) findViewById(R.id.webview1); webView.setWebViewClient(new…
String
  • 3,462
  • 9
  • 39
  • 63
49
votes
3 answers

Alternate Solution for setJavaScriptEnabled(true);

I have developed an Android Application which uses Webview Component. I have used following line into my code, webViewScores.getSettings().setJavaScriptEnabled(true); Due to this line it is showing Lint warning as Using setJavaScriptEnabled can…
Vigbyor
  • 2,334
  • 4
  • 18
  • 34