当我使用ua(userAgent)字符串时,webview会显示桌面版本的网站。 这是我用过的字符串:
mWebView.getSettings().setUserAgentString("AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");这里是我试图在我的网站打开的网站
http://groupedirectouest.com/它适用于Chrome而不是webview。
import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { private WebView mWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.web_view); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new CustomWebViewClient()); mWebView.loadUrl("http://groupedirectouest.com"); } } class CustomWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }when I use ua (userAgent) string, webview shows desktop version of website. here is the ua string i have used :
mWebView.getSettings().setUserAgentString("AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");here is the website that i am trying to open in my
http://groupedirectouest.com/it works fine with chrome but webview.
最满意答案
现在有为您定制的铬标签!
如果您在应用程序内托管自己的内容,WebView是一个很好的解决方案。 如果您的应用引导用户访问您网域之外的网址,现在建议您使用Chrome自定义标签获得各种优惠。 按照下面的链接:
https://developer.chrome.com/multidevice/android/customtabs
Now there are custom chrome tabs for you!
The WebView is good solution if you are hosting your own content inside your app. If your app directs people to URLs outside your domain,it is now recommended that you use Chrome custom tabs for various benefits.Follow the link below:
https://developer.chrome.com/multidevice/android/customtabs
更多推荐
发布评论