Show whatsapp barcode webpage in webview

限于喜欢 提交于 2019-12-24 07:47:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!