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.

7462 questions
77
votes
9 answers

Memory leak in WebView

I have an activity using an xml layout where a WebView is embedded. I am not using the WebView in my activity code at all, all it does is sitting there in my xml layout and being visible. Now, when I finish the activity, I find that my activity is…
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
76
votes
8 answers

WebView: how to 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) { handler.proceed(); } I…
76
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
  • 75,930
  • 30
  • 170
  • 176
75
votes
5 answers

How to load html string in a webview?

i have a html string containing this:
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
74
votes
11 answers

How can I get onclick event on webview in android?

I want to know when the user clicks on webview but not on a hyperlink. On that click I want to show/hide a view of my activity that holds a webview. Any suggestion?
Arslan Anwar
  • 18,746
  • 19
  • 76
  • 105
74
votes
11 answers

Android WebView "tel:" links show web page not found

I am trying to get my android webview app to open tel: links to the phone. Every time I open up a telephone link it works great and opens up the phone. However once I am done with my call and go back to the app it is at a page that says "Web Page…
Jeff Thomas
  • 4,728
  • 11
  • 38
  • 57
72
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
  • 10,349
  • 8
  • 51
  • 72
71
votes
8 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
  • 24,001
  • 13
  • 56
  • 83
66
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…
Eugene Nacu
  • 1,613
  • 2
  • 14
  • 22
65
votes
4 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,568
  • 4
  • 21
  • 35
62
votes
2 answers

Android webview crash "Fatal signal 5 (SIGTRAP)"

I have an app with a web view in which I load HTML content with JavaScript enabled. The web view is inside a fragment. This is how I initialize the web view inside the method onCreateView of the fragment : WebView webview = (WebView)…
Eddybrtn
  • 743
  • 5
  • 9
61
votes
7 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
  • 857
  • 1
  • 11
  • 21
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
  • 88,392
  • 43
  • 149
  • 167
60
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,341
  • 6
  • 34
  • 50
59
votes
12 answers

Android ProgessBar while loading WebView

In my application, I have a WebView which loads any URL from the internet. Now, sometimes due to slow networks the page takes a long time to load and the user sees only a blank screen. I want to show a ProgressBar while the WebView gets loaded and…
Swayam
  • 16,294
  • 14
  • 64
  • 102