I have website url which loads as a full desktop version in my web view instead of mobile version. It loads fine on IOS but not on Android. Is this a problem with user agent not been detected or?
I'm trying to load this website www.mercedesbenzstadium.com
you need to edit the webview settings
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
setLoadWithOverviewMode(true) loads the WebView completely zoomed out
setUseWideViewPort(true) makes the Webview have a normal viewport (such as a normal desktop browser)
Related
I have developed an application in unity then I export it to WebGl then I have created a web page. When I preview the page on Android's Chrome browser there is no any problem, It shows the page in high quality however when I open the page in android WebView quality of graphics dramatically decreases. I have tested the same application on Android 7,8 and 9 but there is no difference between versions. I have tried hardwareAccelerated but the problem is already present. Is it possible to get same quality in WebView like it is in Chrome?
You can give a try to Chrome custom tabs. They are far more performant than a webview and they give to users a seamless in-app user experience.
Unfortunately webview lacks a lot of features of the common browsers and it's not the best choice to display complex web pages.
It is work fine in mobile chrome but cannot display in inAppBrowser.
I want to know that why they have different.
Did I need to add the javascript ti index.html?
An Android app uses a WebView to display a Facebook Like Box. On 4.1.2 and 4.3 the page appears correctly when the following code is used.
String url = "https://www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FGoogle&width&height=395&colorscheme=light&show_faces=false&header=false&stream=true&show_border=false";
WebView webview = (WebView) findViewById(R.id.web_content);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient());
webview.setWebViewClient(new WebViewClient());
webview.loadUrl(url);
On 4.4.2 the page looks good in the full-on Chrome app; however, the behaviour is not good when loaded in the WebView as coded above. There is a brief flash of a fully-rendered page then the WebView goes totally white. Nothing is visible and scrolling does nothing.
I have used chrome://inspect to watch the page as it loads, but it doesn't support showing network requests. The output of running document.location.href; at the console is about:blank, though, which is a clue.
Some ideas I've tried based on various threads:
Disabling hardware acceleration
Using webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null)
Using android:hardwareAccelerated="false" in AndroidManifest.xml
Disabling JavaScript
This can't work because the Like Box requires JS to display at all
Some methods on webview.getSettings()
.setSupportZoom(true), .setSupportZoom(false)
.setUseWideViewPort(true), .setUseWideViewPort(false)
.setLoadWithOverviewMode(true), .setLoadWithOverviewMode(false)
Running custom CSS after the page is loaded to set a white background
I make sure it runs by creating an alert() directly afterward
At this point I may have to resort to starting an intent when running in 4.4 so the page is loaded by the browser in that case, but I would prefer to find a fix for the blank WebView. Are there any other settings I can tweak?
The above doesn't repro for me on 4.4
I have used chrome://inspect to watch the page as it loads, but it doesn't support showing network requests.
It totally does support showing network requests. Try this - in your app comment out loading the URL, just new the WebView up. Connect via DevTools and type
window.location = 'https://....';
The output of running document.location.href; at the console is about:blank, though, which is a clue.
Sounds like this is it. I'm not sure what the HTML/JS you end up loading does, maybe the JS tries to navigate to some weird URL? Try setting a WebViewClient that logs all shouldOverrideUrlLoading calls and see if you're getting a non-http(s) URL there. Try returning true for that URL.
I have one responsive website. I load it in my android application using Webview. In some devise like samsung s2, micromax tablet it load with proper manner with website design. but In some devise like sonyxperia and emulltor I load only text of website not loaded website design. my website is responsive. I used below code to load website
webView=(WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://xyz responsive url");
If any one have solution to load mobile app on android devise then please comment here.
Depending on the Android version you're using, WebView will not be able to render you website as you expect because it is not a full browser, but it has only some HTML rendering capabilities.
Starting on Android 4.4 (KitKat), WebView uses the same rendering engine as Chrome, so the render of your website using WebView should be much more consistent.
Also, WebView in Android < 4.4 won't have support for all JavaScript you may want to run in your webpage.
If you're trying to render an HTML5 webpage, try your WebView component using HTML5test and see if it has support for all the features you want in your webpage.
I have an app out which displays this link in a web view when a user presses e-mail:
https://marauder.millersville.edu/mail/index.pl
I developed the app on an Droid X, and on my phone the link loads fine, but I have had reports from users who have an Incredible & Droid X that the link loads a blank screen.
I have tested it myself on a friends Incredible, and it indeed only loads a white screen, but I have have tested it on various other android devices and its loads fine.
And every other links also loads fine on the Incredible. I am assuming it has something to do with the SSL, being a https. I had troubles with this link on an iPhone but was able to fix it. What puzzles me is why it works fine on some devices and not on others..
Anyone have any ideas or suggestions? Thanks!
Here is how I am setting up my web view:
// setup webview
web = (WebView) findViewById(R.id.webview);
web.setWebChromeClient(new InternalWebViewClient());
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
web.getSettings().setPluginsEnabled(true);
web.getSettings().setSupportMultipleWindows(true);
web.getSettings().setSupportZoom(true);
web.getSettings().setAppCacheEnabled(true);
web.getSettings().setSaveFormData(true);
web.getSettings().setSavePassword(true);
web.getSettings().setBuiltInZoomControls(true);
web.setHorizontalScrollBarEnabled(true);
web.setVerticalScrollBarEnabled(false);
The site you are trying to load uses self signed certificates. The solution is to ignore certificate checking as described here: Does the Web View on Android support SSL?