Reputation: 1994
My Application shows the content of a webpage in a Android webview. The webpage is designed by a 3rd party team and as such I have no control on the design or the source code. The webpage shows some kind of animation to begin with and then refreshes with the actual content (normal UI design). However my webview never goes beyond the initial animation.
Please note that I have verified that the webpage loads properly on a browser on the same device. So there is definitely no problem with the Webpage. Also I have refreshed the webview pro-grammatically after a delay of 5 seconds (On a desktop browser, the webpage takes roughly 1-2 seconds for refreshing the actual content) which should have accounted for the delayed refresh.
Is there any known issue with modern webpages (HTML 5 + CSS3 + JS) that might result them not rendering properly on Android webview ? What can i fallback to ? Am I missing setting any property on the Webview ?
Below is a snippet of my code -
myWebView = (WebView)v.findViewById(R.id.catalog_view);
WebSettings settings = myWebView.getSettings();
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
myWebView.loadUrl("https://www.homehardware.com.au/catalogue/?category=garden-outdoor");
Note : The URL mentioned in teh codeis the actual URL i am trying to load. I have also tried couple of other things, like fiddling with the webview cache mode, UA string etc. but nothing works.
Upvotes: 6
Views: 8715
Reputation: 203
try this
webView.loadDataWithBaseURL(null, htmlContent, "text/html", "UTF-8", null)
Upvotes: 0
Reputation: 374
The below two settings should be there to avoid webview caching to update the page without refresh
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setDomStorageEnabled(true);
Upvotes: 7
Reputation: 1994
Just to close the question for future reference for SO explorers, the answer is from the upvoted comment by praveen.
The trick is to use settings.setDomStorageEnabled(true)
Note : although as per my opinion, with HTML5 becoming one of the defacto standards on which modern web pages are based, this setting should by default be enabled on Android webviews (so that webviews by default behave the way modern browsers do)
Upvotes: 0