蹒跚走路的程序猿

Android WebView useragent

     今天介绍一下Android WebView UserAgent, User-Agent(简称UA)是HTTP请求头部用来标识客户端信息的字符串, 包括操作系统, 浏览器等信息。为了建立手机客户端的信息数据库,需要从手机的http请求中取到这一字符串。

   获取UA:

1 mWebView = (WebView) findViewById(R.id.page_webview);
2         mWebView.getSettings().getUserAgentString();

    UA的值:

Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; MI 2S Build/JRO03L) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

    设置UA:

1 mWebView = (WebView) findViewById(R.id.page_webview);
2         mWebView.getSettings().setUserAgentString("MicroMessager");

  UA的值:

1 MicroMessager

 

posted on   蹒跚走路的程序猿  阅读(11413)  评论(0编辑  收藏  举报

努力加载评论中...
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示