If being android developer you stuck and searching for many question's answer related networking connection. Volley android sdk Gives the answer
Volley fixed these problems
1) All network requests happen serially
2) Rotating the screen will reload everything from the network
3) AsyncTasks stomp on recycled views
4) Compatibility problems on Froyo
Then curiously how's the documentation of android volley going to be !!Answer is Very simple
Volley Android library Implementation
Initializing Volley android before use anywhere in Constructer which called very first time
// Somewhere common; app startup or adapter constructor
mRequestQueue = Volley.newRequestQueue(context);
mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache());
Making request to URL which gives Json Response
mRequestQueue.add(new JsonObjectRequest(Method.GET, url, null,
new Listener<JSONObject>() {
public void onResponse(JSONObject jsonRoot) {
mNextPageToken = jsonGet(jsonRoot, "next", null);
List<Items> items = parseJson(jsonRoot);
appendItemsToList(item);
notifyDataSetChanged();
}
}
}
Image Loading through volley contain two way
- Using ImageLoader class
mImageLoader.get(image_url,imageView, R.drawable.loading, R.drawable.error);
- Using Volley Android Custom ImageView
- <ImageView
+ <com.android.volley.NetworkImageView
Java mImageView.setImageUrl(BASE_URL + item.image_url, mImageLoader);
There are a lot more in Volley android. Download Sample and check them out
No comments:
Post a Comment
Feedback always help in improvement. If you have any query suggestion feel free to comment and Keep visiting my blog to encourage me to blogging