Note the points in your study:
1. To join the Internet permission in Androidmanifest.xml
<uses-permission android:name= "Android.permission.INTERNET"/>
2, suitable for the use of single-case design mode, reduce duplication of code
Mysingleton.java
public class Mysingleton {private static Mysingleton minstance;private requestqueue mrequestqueue;private imageloader Mimageloader;private static context Mctx; @SuppressLint ("Newapi") private Mysingleton (context context) {Mctx = context; Mrequestqueue = Getrequestqueue (); mimageloader = new Imageloader (mrequestqueue,new Imagecache () {Private final LruCache <string,bitmap>cache = new lrucache<string,bitmap>, @TargetApi (build.version_codes. HONEYCOMB_MR1) @SuppressLint ("Newapi") @Overridepublic void Putbitmap (String url, Bitmap Bitmap) {cache.put (URL, Bitmap );} @Overridepublic Bitmap getbitmap (String URL) {return cache.get (URL);}});} public static synchronized Mysingleton getinstance (context context) {if (minstance = = null) {minstance = new Mysingleton ( context);} return minstance;} Public Requestqueue Getrequestqueue () {if (Mrequestqueue = = null) {//Getapplicationcontext () is key, it keeps you from leak ing the//Activity or broadcastreceiver if someone passes one in.mrequestqueUE = Volley.newrequestqueue (Mctx.getapplicationcontext ());} return mrequestqueue;} Public <T> void Addtorequestqueue (request<t> req) {getrequestqueue (). Add (req);} Public Imageloader Getimageloader () {return mimageloader;}}
Official Learning Website:
Http://developer.android.com/training/volley (often not open)
Http://www.cnblogs.com/bvin/p/4350731.html (official excerpt from the blogger)
Share Summary:
http://blog.csdn.net/guolin_blog/article/details/17482095 (Volley fully parse one ~ four)
http://blog.csdn.net/chenfuduo_loveit/article/details/41773607 (translated by Bo)
http://codekk.com/open-source-project-analysis/detail/Android/grumoon/Volley%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6% 9e%90 (source parsing of Codekk)
Android Open Source Learning Volley