Volley
private void volley_get() {
String url = "https://www.baidu.com/";
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener() {
@Override
public void onResponse(String response) {
//成功的回调
System.out.println("成功返回:"+response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//失败的回调
System.out.println("失败返回:"+error.getMessage());
}
});
request.setTag("abcGet");//设置标签,通过标签在队列中寻找,所以名字尽量有意义
MyApplication.getHttpQueues().add(request);//加入到全局队列
}