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
112
votes
3 answers

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 and make a string the key and the value is the…
Sherzod
  • 5,041
  • 10
  • 47
  • 66
110
votes
8 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…
109
votes
16 answers

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.getSettings().setJavaScriptEnabled(true); …
sumit
  • 1,091
  • 2
  • 8
  • 3
106
votes
8 answers

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 in fullscreen mode. As I figured out, android has…
nbtk
  • 3,039
  • 4
  • 21
  • 19
106
votes
12 answers

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 from the loadUrl() method. Any idea what's wrong…
mark
  • 2,841
  • 4
  • 25
  • 23
105
votes
4 answers

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 to do Make a webview (worked) calling in…
Johan Hoeksma
  • 3,534
  • 5
  • 28
  • 40
93
votes
6 answers

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, and using: private WebView…
laph
  • 2,925
  • 2
  • 18
  • 18
92
votes
7 answers

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 a string, but alas it does not. If I enable…
gregm
  • 12,019
  • 7
  • 56
  • 78
90
votes
13 answers

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 WebView? Something similar to iPhones prevention…
Jake Sankey
  • 4,977
  • 12
  • 39
  • 53
87
votes
3 answers

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
  • 2,752
  • 2
  • 17
  • 38
81
votes
13 answers

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 xml properties with left and right attributes to…
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
80
votes
9 answers

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 WebView is to start at a 100% pixel scale so it…
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171
79
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,795
  • 15
  • 52
  • 61
78
votes
5 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
  • 1,031
  • 1
  • 11
  • 20
78
votes
3 answers

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 WebChromeClient { public boolean onJsAlert(WebView view,…
ozkolonur
  • 1,430
  • 1
  • 15
  • 22