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
493
votes
10 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
  • 15,087
  • 5
  • 26
  • 50
473
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
  • 176,216
  • 111
  • 293
  • 365
358
votes
17 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
  • 5,756
  • 7
  • 30
  • 41
264
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,285
  • 8
  • 27
  • 43
255
votes
7 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
  • 8,159
  • 3
  • 14
  • 7
210
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
  • 6,937
  • 13
  • 40
  • 54
194
votes
5 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,170
  • 10
  • 34
  • 55
150
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
  • 1,883
  • 2
  • 8
  • 16
149
votes
4 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,287
  • 3
  • 23
  • 28
133
votes
14 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,134
  • 5
  • 22
  • 27
128
votes
7 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,322
  • 9
  • 32
  • 42
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
119
votes
6 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,439
  • 3
  • 12
  • 11
113
votes
21 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,539
  • 5
  • 17
  • 20
108
votes
7 answers

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 a fragment in a viewpager. When I first load the…
1
2 3
99 100