Android mobile user agent?

妖精的绣舞 提交于 2019-11-30 12:23:55

This is an example of user agent for android:

Mozilla/5.0 (Linux; U; Android 2.2; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

And you can use simply:

myWebView.getSettings().setUserAgentString("Android");

As 2019 for Android devices have a look to: https://developer.chrome.com/multidevice/user-agent

So as documentation says:

WebView UA in Lollipop and Above

In the newer versions of WebView, you can differentiate the WebView by looking for the wv field as show in bold below.

Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36

Use webview.getSettings().setUserAgent(int); in the int parameter ,0 is a mobile browser while 1 is desktop browser

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