Android应用开发中怎么修改http请求头中的User-Agent:例如android2.2中http的User-Agent是Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91;) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safafi/533.1\r\n
怎么把它修改成为Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91; csdncsdncsdncsdncsdncsdncsdncsdn) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safafi/533.1\r\n这只是打个比方,也可以将他部分字符串修改、追加!本人深受折磨,望各位解救!走过路过的看官,帮帮忙告知一下,不甚感激!
------解决方案--------------------
webView可以setUserAgentString
- Java code
mwebView = new WebView(mContext); WebSettings set = mwebView.getSettings();set.setUserAgentString(SmartConfig.getWebUserAgent(mContext));