Android网络通信架构——Volleyjava
一、 Volley提供的功能
简单来讲,它提供了以下的便利功能:android
二、学习前的准备:下载volley源码打成jar包(我经过这个网址下载不下了,可是网络上不少好心人已经分享了源码)git
下载地址:缓存
mirror of volley library from android source网络
from :
https://android.googlesource.com/platform/frameworks/volley架构
original:
git clone https://android.googlesource.com/platform/frameworks/volley异步
update weekly from android source repoide
三、正式开工:学习
简单例子:this
private void getStringVolley() { RequestQueue requestQueue = Volley.newRequestQueue(this); StringRequest sRequest=new StringRequest(Request.Method.GET,CITY_CODE_URL, new Listener<String>() { @Override public void onResponse(String response) { System.out.println(response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { System.out.println("sorry,Error"); } }); sRequest.setShouldCache(false); requestQueue.add(sRequest); }