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.
android-webview
7,479
questions
533
votes
11
answers
233k
views
Android webview launches browser when calling loadurl
I created an Activity that has a title and a web view in a LinearLayout. In the onResume() method it calls webView.loadUrl(url). The problem is that the activity first shows the title with the rest of ...
505
votes
18
answers
427k
views
How to listen for a WebView finishing loading a URL?
I have a WebView that is loading a page from the Internet. I want to show a ProgressBar until the loading is complete.
How do I listen for the completion of page loading of a WebView?
402
votes
18
answers
324k
views
How to go back to previous page if back button is pressed in WebView?
I have an app in which I have a WebView where I display some websites. It works, clicking a link in the webpage goes to the next page in the website inside my app. But when I click the phone's back ...
297
votes
8
answers
184k
views
Android webview & localStorage
I have a problem with a webview which may access to the localStorage by an HTML5 app. The test.html file informs me that local
storage is'nt supported by my browser (ie. the webview). If you have any ...
288
votes
8
answers
351k
views
Android Calling JavaScript functions in WebView
I am trying to call some javascript functions sitting in an html page running inside an android webview. Pretty simple what the code tries to do below - from the android app, call a javascript ...
221
votes
2
answers
357k
views
WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS [duplicate]
I'm starting to work on an app on Android, so I don't have much. All I have is just a WebView so far. I created the project in Android Studio, and my project got set as an Android InstantApp. I'm not ...
215
votes
6
answers
144k
views
Clicking URLs opens default browser
I have loaded an external URL in my WebView. Now what I need is that when the user clicks on the links on the page loaded, it has to work like a normal browser and open the link in the same WebView. ...
206
votes
6
answers
214k
views
Load HTML file into WebView
I have a local html page along with several other resources pointed by it (css files and Javascript libraries) that I would like to load into a WebView . How could this be achieved ?
Perhaps not the ...
173
votes
5
answers
136k
views
Is `shouldOverrideUrlLoading` really deprecated? What can I use instead?
Is "shouldOverrideUrlLoading" really deprecated? If so, what can I use instead?
It seems like shouldOverrideUrlLoading is deprecated targeting Android N and I need to make an app work since API 19 ...
145
votes
9
answers
200k
views
Android WebView, how to handle redirects in app instead of opening a browser
So right now in my app the URL I'm accessing has a redirect, and when this happens the WebView will open a new browser, instead of staying in my app. Is there a way I can change the settings so the ...
136
votes
15
answers
309k
views
How to load external webpage in WebView
My problem is that the webpage is not loaded inside the WebView.
mWebview.loadUrl("http://www.google.com"); launches the web browser...
This is the code of my activity:
import android.app....
134
votes
7
answers
145k
views
WebView link click open default browser
Right now I have an app that loads a webview and all the clicks are kept within the app. What I would like to do is when a certain link, for example, http://www.google.com is clicked within the app it ...
131
votes
22
answers
285k
views
Android Webview - Webpage should fit the device screen
I have tried the following to fit the webpage based on the device screen size.
mWebview.setInitialScale(30);
and then set the metadata viewport
<meta name="viewport" content="width=320, initial-...
129
votes
13
answers
180k
views
Add custom headers to WebView resource requests - android
I need to add custom headers to EVERY request coming from the WebView. I know loadURL has the parameter for extraHeaders, but those are only applied to the initial request. All subsequent requests ...
125
votes
13
answers
152k
views
WebView and HTML5 <video>
I'm piecing together a cheapo app that amongst other things "frames" some of our websites... Pretty simple with the WebViewClient. until I hit the video.
The video is done as HTML5 elements, and ...
114
votes
3
answers
76k
views
Is there a limit on length of the key (string) in JS object?
So we had a case where we would have an object, where key is id (int) and the value is the string. But we noticed that most of the times, we look up id based on the string, so we decided to reverse it ...
110
votes
8
answers
38k
views
How to prevent a scrollview from scrolling to a webview after data is loaded?
So I have a fascinating problem. Despite the fact that I'm not manually or programmatically scrolling my view, my WebView is being automatically scrolled to after the data inside it loads.
I've got ...
109
votes
17
answers
191k
views
Android WebView not loading an HTTPS URL
public void onCreate(Bundle savedInstance)
{
super.onCreate(savedInstance);
setContentView(R.layout.show_voucher);
webView=(WebView)findViewById(R.id.webview);
webView....
107
votes
12
answers
84k
views
Android - Preventing WebView reload on Rotate
When I rotate my screen, the WebView reloads the whole page. I can't have this since some of my content contains dynamic/random material. Currently when rotated the screen reloads the original URL ...
106
votes
4
answers
69k
views
WebView methods on same thread error
I have a android program (Java + html in a webview). I can call from the javascript to the Java code. But the other way around stopped working (after updating in eclipse).
So this is what I'm trying ...
106
votes
9
answers
178k
views
Playing HTML5 video on fullscreen in android webview
Well, I've been searching few days already, how to display HTML5 video in full-screen mode on android WebView.
I managed to play HTML5 videos on my webview. Problems are arising when displaying video ...
93
votes
6
answers
153k
views
Loading existing .html file with android WebView
I did try samples, demos from Google codes and other resources with WebView, but when i try to do it in my own code, it doesn't work for me.
I want to load myfile.html which i put in assets folder, ...
92
votes
7
answers
121k
views
How do I get the web page contents from a WebView?
On Android, I have a WebView that is displaying a page.
How do I get the page source without requesting the page again?
It seems WebView should have some kind of getPageSource() method that returns ...
90
votes
13
answers
162k
views
Disable scrolling in webview?
Until now I have been an iPhone developer only and now I have decided to give Android a whirl. Something I haven't been able to figure out on Android is how to programmatically prevent scrolling in a ...
90
votes
4
answers
34k
views
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.
<body>
<button type="button" onclick="testClipboard();">...
83
votes
13
answers
24k
views
Android - WebView language changes abruptly on Android 7.0 and above
I have a multilingual app with primary language English and secondary language Arabic.
As described in the documentation,
I have added android:supportsRtl="true" in the manifest.
I have changed all ...
81
votes
5
answers
96k
views
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){
...
80
votes
9
answers
118k
views
How to set the initial zoom/width for a webview
I am trying to get the WebView to have similar behavior as the android browser. The browser opens all pages in a way that tries to fit their width to the screen. However, the default behavior of the ...
79
votes
5
answers
98k
views
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 ...
79
votes
3
answers
75k
views
Call Java function from JavaScript over Android WebView
I want to make a synchronous call to some Java code in my Android app.
I am using this solution:
https://stackoverflow.com/a/3338656
My Java code:
final class MyWebChromeClient extends ...
77
votes
5
answers
146k
views
How to load html string in a webview?
i have a html string containing this:
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<meta http-equiv="content-type" content="...
77
votes
6
answers
138k
views
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<String>() {
@...
77
votes
9
answers
71k
views
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 ...
76
votes
11
answers
81k
views
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 ...
76
votes
8
answers
69k
views
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,...
75
votes
7
answers
135k
views
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 ...
74
votes
11
answers
142k
views
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?
72
votes
8
answers
100k
views
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 ...
66
votes
8
answers
137k
views
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 ...
65
votes
4
answers
33k
views
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 ...
62
votes
7
answers
140k
views
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 ...
62
votes
2
answers
8k
views
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 ...
61
votes
11
answers
94k
views
Android - local image in webview
I'm trying to diplay a local image in my webview :
String data = "<body>" + "<img src=\"file:///android_asset/large_image.png\"/></body>";
webview.loadData(data, "text/html", "UTF-...
61
votes
2
answers
18k
views
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 ...
60
votes
12
answers
93k
views
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 ...
57
votes
11
answers
192k
views
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 HostsWebClient());
webView.getSettings()....
57
votes
4
answers
71k
views
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 ...
53
votes
11
answers
77k
views
Android WebView, Scaling Image to fit the screen
What I have: I'm loading image from a URL. I simply do (WebView).loadUrl(imageurl, extraheaders)
What I get: Image is not showing at full width of the WebView, it has blank space all around (like if ...
52
votes
7
answers
70k
views
How to debug webview remotely?
How can I do debug/inspect element of apk webview.
I have tried this but it is helpful only for chrome not for apk.
Please suggest me
51
votes
5
answers
73k
views
How to enable javascript into webView
In android if I use javascript into webView it gives Force Close. Is there any possibilities for using java script into webView. please help...
01-10 10:08:51.513: W/dalvikvm(5994): JNI WARNING: ...