Android 7.0 Nouget Webview can't show all images - android

When I load a url in "Android 7.0",there are some images showing correctly but some images whose url is correct are blank in the emulator.All these images can show correctly in "Android 6.0". This is the code:
webview = new WebView(getApplicationContext());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setBlockNetworkImage(false);
webview.addJavascriptInterface(new MJavascriptInterface(this,imageUrls), "imagelistener");
webview.setWebViewClient(new MyWebViewClient());
webview.loadUrl(urlStr);

Related

In Android, why does a webpage display correctly on Google Chrome and not in a WebView?

My webpage works fine on Google Chrome on my Android phone, but it does not display well when I load it inside a WebView.
My WebView settings as follows:
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setDatabaseEnabled(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
What could be the problem?
Try this before the settings but after you put in the URL
nameOfWebView.setDrawingCacheEnabled(true);
nameOfWebView.buildDrawingCache();
webview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);

WebView fails to render certain webpages

I'm trying to show 2 webpages in WebViews. The 1st one works fine, but the 2nd will result in a blank screen.
This happens on Android 4.2.2, if I run this on a Lollipop it works fine. Moreover, I tried saving the page to the assets folder in my project and it could load properly that way.
Here are the URLs I am trying to load:
1. http://www.taiwanjobs.gov.tw/mobileApp/docDetail_frame.aspx?uid=411&pid=221&docid=141
2. http://www.taiwanjobs.gov.tw/mobileApp/docList_frame.aspx?uid=412&pid=221
Here is my code:
final WebView webView = (WebView) getView().findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient());
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.loadUrl(url);
Please help me. Thanks!
You should try this code...
I think you have to override the urlloading as below code...
webView = (WebView) view.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new webViewClient());
webView.loadUrl(url);
private class webViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
So... turns out the issue was from the webpage itself,
WebView in Android 4.2.2 just wasn't supporting it,
I tried opening it with the web browser on an Android 4.2.2 emulator,
same results.

Android WebView can't display jquery-fullpage page properly

The page is implemented by jquery-fullpage plugin, like this:
http://alvarotrigo.com/fullPage/#firstPage
In android app, WebView doesn't display it properly. It overlaps all the sub pages in one page without scrollbar.
Any idea?
Version of your browser maybe affect. Check issue on Github.
Remember enable javascript in your WebView:
WebView webView = (WebView) findViewById(R.id.webview);
webView = (WebView) findViewById(R.id.webview);
webView.clearCache(true);
webView.clearHistory();
/* Enabling javascript */
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

url loads differently in browser and webview

I am loading a url for my app. When I load the url in a browser it loads the right content. But when I load it in a webview I get a different content.
Here is my code:-
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl(url);
myWebView.setWebViewClient(new WebViewClient());
What can be going wrong?

How to display image in webview android?

I am working on android. I am trying to display the page data in webview. i.e actually i am getting the data from php webservice. The result of that php webservice is
a document with images and text.(If we right click on that page and view page source it is all the html data). But now what I am doing is I am setting the php link to the webview. So now, it is display fine in webview (same as how it is displaying in webpage). But now the document contains some images which are displaying in website but those images are not displaying in webview. What should I do now? Please help me in this regard.
Code:
WebView webview;
WebSettings settings;
link = "http://.............../page.php?test=123&test1=345"
webview = (WebView) findViewById(R.id.webView1);
settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setPluginState(PluginState.ON);
webview.loadUrl(link);
please add this line,
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);

Categories

Resources