使用android-async-http设置Header解决不了就用xutils3,用xutils3不行就用android-async-http,反正哪个能用就用哪个。
compile 'com.loopj.android:android-async-http:1.4.9'
网址:
https://github.com/loopj/android-async-http
AsyncHttpClient client = new AsyncHttpClient();
//设置USerAgent模拟PC访问
client.setUserAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows 7)");
client.get(url, new TextHttpResponseHandler() {
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
}
@Override
public void onSuccess(int statusCode, Header[] headers, String responseString) {
}
});