问题
I am trying to show this link in android app in webview but the web loads in android device is different from showing in Google Chrome.
Whatsapp link is here :https://web.whatsapp.com/
I am using this code in android to load the above page but it does not load the same page.
mWebView .loadUrl("https://web.whatsapp.com/");// https://tekdude.blogspot.in/");
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
setContentView(mWebView );
回答1:
You can try with changing user agent of your web view.
Example:
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);
Check this link Setting WebView to view Desktop Site and Not Mobile Site
回答2:
Change the user agent of webview like
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);
Alternatively you can also change the settings without changing user agent
webView = (WebView)findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
来源:https://stackoverflow.com/questions/42175191/show-whatsapp-barcode-webpage-in-webview