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
529
votes
11 answers

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 the screen blank, then the device browser is…
Ray
  • 16,025
  • 5
  • 31
  • 51
502
votes
18 answers

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?
Janusz
  • 187,060
  • 113
  • 301
  • 369
402
votes
18 answers

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 button, it takes me straight into my app. I want to…
zvzej
  • 6,276
  • 7
  • 33
  • 41
292
votes
8 answers

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 suggestion.. package com.test.HelloWebView;…
Thomas
  • 9,299
  • 3
  • 16
  • 7
284
votes
8 answers

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 function with a test message, which inturn calls a java…
user163757
  • 6,795
  • 9
  • 32
  • 47
215
votes
6 answers

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. But it's opening the default browser and loading…
JaVadid
  • 7,107
  • 13
  • 42
  • 54
214
votes
2 answers

WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS

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 sure why/how, but my guess is that I overlooked…
tylerr147
  • 2,581
  • 2
  • 11
  • 16
206
votes
6 answers

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 best way to procede but I'm still experimenting.
klaus johan
  • 4,370
  • 10
  • 39
  • 56
170
votes
5 answers

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 until the latest right now which is Android N…
Minion
  • 2,497
  • 4
  • 27
  • 29
143
votes
9 answers

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 View will redirect to the URL like normal, but stay…
James
  • 5,622
  • 9
  • 34
  • 42
136
votes
15 answers

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.Activity; import android.os.Bundle; import…
Gilbou
  • 5,244
  • 6
  • 24
  • 27
131
votes
22 answers

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
SWDeveloper
  • 1,749
  • 5
  • 18
  • 20
130
votes
7 answers

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 opens the default browser. If anyone has some…
Kyle
  • 1,589
  • 3
  • 12
  • 11
127
votes
12 answers

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 do not contain the headers. I have looked at all…
Ray
  • 1,413
  • 2
  • 10
  • 12
125
votes
13 answers

WebView and HTML5

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 these work fine and dandy on Chrome, iPhones, and…
brian moore
  • 1,263
  • 2
  • 9
  • 6
1
2 3
99 100