How to send holder view to AsyncTask in ArrayAdapter - android

I'm sending the holder view to volley method in ArrayAdapter like
final ViewHolder finalHolder = holder;
holder.rlLike.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
userLikes(finalHolder);
}
});
private void userLikes(final ViewHolder finalHolder){
StringRequest request = new StringRequest(Request.Method.POST, user_likes_url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
if(response != null){
Log.e("LikeResponse", response);
try {
JSONObject jsonObject = new JSONObject(response);
//toastShort(activity, user_likes_obj.getString("data"));
if(jsonObject.getString("status").equals("success")){
finalHolder.userLikeImage.setImageResource(R.drawable.icon_pop_like);
finalHolder.tvLike.setText("Unlike");
}else {
}
} catch (JSONException e) {
e.getLocalizedMessage();
e.printStackTrace();
}
}else{
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.e("error", error.toString());
}
}){
#Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
Log.e("action", user_likes);
params.put("action",user_likes);
return params;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
RequestQueue queue = Volley.newRequestQueue(context);
queue.add(request);
queue.getCache().remove(user_likes_url);
}
After getting the successful response from the server I'm changing the ImageView and TextView like
finalHolder.userLikeImage.setImageResource(R.drawable.icon_pop_like);
finalHolder.tvLike.setText("Unlike");
But I want to send the holder view to asynchronus task and bassed on the server response I want to change ImageView and TextView as above
My AsyncTask task code is
private void userLikes(String likeStatus){
class carRegAsynTask extends AsyncTask<String, Void, String>{
//ProgressDialog dialog;
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
String likeStatusParam = params[0];
BasicNameValuePair likeStatus = new BasicNameValuePair("action", likeStatusParam);
List<NameValuePair> listValuePairs = new ArrayList<NameValuePair>();
listValuePairs.add(likeStatus);
Log.e("listValuePairs", listValuePairs.toString());
String Url = user_likes_url;
Log.e("Url", Url);
String response = POST_METHOD(listValuePairs, Url);
return response;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (result != null) {
Log.e("LikeResult2", result);
try {
JSONObject jsonObject = new JSONObject(result);
if(jsonObject.getString("status").equals("success")){
userLikeImage.setImageResource(R.drawable.icon_pop_un_like);
tvLike.setText("Like");
}else {
}
} catch (JSONException e) {
e.getLocalizedMessage();
e.printStackTrace();
}
}
}
}
new carRegAsynTask().execute(likeStatus);
}
So please help me to send the holder view to Asynchronus task like in the volley method I discussed above, and don't forget it is an ArrayAdapter

Although this is not a good practice to hold strong references to views from asynchronous tasks, you can pass whatever you need to your carRegAsynTask. Just create a constructor and pass all the needed data as parameters.
UPDATE
Example:
class carRegAsynTask extends AsyncTask<String, Void, String>{
private final ViewHolder viewHolder;
public carRegAsynTask(ViewHolder viewHolder) {
this.viewHolder = viewHolder;
}
// omitted for brevity...
// Use your viewHolder in onPreExecute or onPostExecute
}
// Creating async task with your viewHolder:
new carRegAsynTask(viewHolder).execute(likeStatus);

I don't know whether it follow able or not, but i achieved it in this way
private void userLikes(final ViewHolder finalHolder) {
class userLikesAsynTask extends AsyncTask<String, Void, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
BasicNameValuePair userid = new BasicNameValuePair("action", user_likes);
List<NameValuePair> listValuePairs = new ArrayList<NameValuePair>();
listValuePairs.add(userid);
Log.e("listValuePairs", listValuePairs.toString());
String userLikesUrl = user_likes_url;
Log.e("userLikesUrl", userLikesUrl);
String response = POST_METHOD(listValuePairs, userLikesUrl);
return response;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (result != null) {
Log.e("userLikesUrlResult", result);
try {
JSONObject jsonObject = new JSONObject(result);
if(jsonObject.has("status")){
if(jsonObject.getString("status").equals("success")){
finalHolder.userLikeImage.setImageResource(R.drawable.icon_pop_like);
finalHolder.tvLike.setText("Unlike");
}else {
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
new userLikesAsynTask().execute();
}

Related

Get JSON string from onPostExecute to OnCreateView

I need get var s (commnet) to onCreatView from onPostExecute (Async Task( in order to draw chart.
Here my code:
I try many solution but i cant do this.
String url;
HashMap<String, String> params;
int requestCode;
PerformNetworkRequest3(String url, HashMap<String, String> params, int requestCode) {
this.url = url;
this.params = params;
this.requestCode = requestCode;
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
JSONObject object = new JSONObject(s);
if (!object.getBoolean("error")) {
Toast.makeText(getContext(), object.getString("message"), Toast.LENGTH_SHORT).show();
s = (object.getString("category")); //need var s -> oncreateview
}
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
protected String doInBackground(Void... voids) {
RequestHandler requestHandler = new RequestHandler();
if (requestCode == CODE_POST_REQUEST)
return requestHandler.sendPostRequest(url, params);
if (requestCode == CODE_GET_REQUEST)
return requestHandler.sendGetRequest(url);
return null;
}
Just make an callback interface. Final solution would be.
new PerformNetworkRequest3("", new HashMap<>(), 0, new PerformNetworkRequest3.OnResult() {
#Override
public void onSuccess(String s) {
// check response here.
}
#Override
public void onError() {
}
});
And replace below with your AsyncTask
import android.os.AsyncTask;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
/**
* Created by KHEMRAJ on 7/23/2018.
*/
public class PerformNetworkRequest3 extends AsyncTask<Void, Void, String> {
String url;
HashMap<String, String> params;
int requestCode;
private OnResult onResult;
private interface OnResult{
void onSuccess(String s); // you can change this String to any, like JsonObject
void onError();
}
PerformNetworkRequest3(String url, HashMap<String, String> params, int requestCode, OnResult onResult) {
this.url = url;
this.params = params;
this.requestCode = requestCode;
this.onResult = onResult;
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
JSONObject object = new JSONObject(s);
onResult.onSuccess(s);
if (!object.getBoolean("error")) {
Toast.makeText(getContext(), object.getString("message"), Toast.LENGTH_SHORT).show();
s = (object.getString("category")); //need var s -> oncreateview
}
} catch (JSONException e) {
e.printStackTrace();
onResult.onError();
}
}
#Override
protected String doInBackground(Void... voids) {
RequestHandler requestHandler = new RequestHandler();
if (requestCode == CODE_POST_REQUEST)
return requestHandler.sendPostRequest(url, params);
if (requestCode == CODE_GET_REQUEST)
return requestHandler.sendGetRequest(url);
return null;
}
}
It is just a implementation. You can change callback methods according to your need. Also manage onError() and onSucess() properly.
Try this:-
String url;
HashMap<String, String> params;
int requestCode;
public AsyncResponse delegate=null;
public interface AsyncResponse {
void processFinish(String output);
}
PerformNetworkRequest3(Context ctx, AsyncResponse asyncResponse) {
context = ctx;
delegate = asyncResponse;
}
PerformNetworkRequest3(String url, HashMap<String, String> params, int requestCode) {
this.url = url;
this.params = params;
this.requestCode = requestCode;
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
try {
JSONObject object = new JSONObject(s);
if (!object.getBoolean("error")) {
Toast.makeText(getContext(), object.getString("message"), Toast.LENGTH_SHORT).show();
s = (object.getString("category")); //need var s -> oncreateview
delegate.processFinish(s);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
#Override
protected String doInBackground(Void... voids) {
RequestHandler requestHandler = new RequestHandler();
if (requestCode == CODE_POST_REQUEST)
return requestHandler.sendPostRequest(url, params);
if (requestCode == CODE_GET_REQUEST)
return requestHandler.sendGetRequest(url);
return null;
}
In your main activity you should implements interface AsyncResponse and overrides its method to get the value.
MainActivity.java
PerformNetworkRequest3 performNetworkRequest3 = new PerformNetworkRequest3(this, new PerformNetworkRequest3 .AsyncResponse() {
#Override
public void processFinish(Boolean output)
{
Toast.makeText(MainActivity.this, "OUTPUT " + output, Toast.LENGTH_SHORT).show();
}
});
performNetworkRequest3.execute("url", "hash_map", "requestCode");

i want send json file to my server from android what should i do in doInBackground method?

my backend is laravel and i want to send json file to a specific rout
i already create my json plz help
public class MainActivity extends AppCompatActivity {
EditText usernameview;
EditText passwordview;
private static final String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usernameview = (EditText)findViewById(R.id.username) ;
passwordview = (EditText)findViewById(R.id.password) ;
Button login = (Button) findViewById(R.id.loginid);
}
public void senddatatoserver(View v) {
String username= usernameview.getText().toString();
String password = passwordview.getText().toString();
JSONObject login = new JSONObject();
try {
login.put("username",username);
login.put("password",password);
} catch (JSONException e) {
e.printStackTrace();
}
if (login.length() > 0) {
new SendDataToServer().execute(String.valueOf(login));
}
}
here is my class to send data i just wanna know what i should write in doinbackground methode
class SendDataToServer extends AsyncTask<String,String,String> {
#Override
protected String doInBackground(String... params) {
}
#Override
protected void onPostExecute(String s) {
}
}
you can use volley to send request
StringRequest stringRequest = new StringRequest(Request.Method.POST, YOUR_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
for (int i = 0; i < response.length(); i++) {
JSONObject json; // convert String to JSONObject
try {
json = new JSONObject(response);
JSONArray jsonArray = json.getJSONArray("data");
lyric_string = jsonArray.getJSONObject(0).getString("song_lyric");
artist_string = jsonArray.getJSONObject(0).getString("song_artist");
//album_string = jsonArray.getJSONObject(0).getString("song_album");
} catch (JSONException e) {
e.printStackTrace();
}
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//error message
dismissDialog();
lyric.setText("Sorry No Lyric Found");
lyric.setVisibility(View.VISIBLE);
}
}) {
#Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("song_name", "A song Name");
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);

How can I post data with Volly and receive JSON object

I want to post an int to an https address and pass 3 JSON objects to text views and I can't get JSON results. I've tried to use methods in onResponse but it's not working. How can I POST an integer and parse some JSON objects to text views? I'm a beginner in Android developing and I don't know how to resolve this problem.
What's the problem? please help
if(isNetworkAvailable()){
RequestQueue queue = Volley.newRequestQueue(this);
String url = "https://example.com/api";
StringRequest postRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<JSONObject>()
{
#Override
public void onResponse(JSONObject response) {
try {
Log.d("Response", response);
} catch (JSONException e) {
e.printStackTrace();
alertUserAboutError();
}
}
},
new Response.ErrorListener()
{
#Override
public void onErrorResponse(VolleyError error) {
// error
mStoreName.setText("Error");
}
}
) {
#Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("category_id", "28");
return params;
}
};
queue.add(postRequest);
}
Toast.makeText(this, "Network is unavailable!", Toast.LENGTH_LONG).show(); }
private void updateDisplay() {
mStoreName.setText(mStoreDetails.getStoreName());
mInstagram.setText(mStoreDetails.getInstagram());
mTelegram.setText(mStoreDetails.getTelegram());
}
private StoreDetails getStoreDetails(String jsonData) throws JSONException {
JSONObject JSONRequest = new JSONObject(jsonData);
StoreDetails storeDetails = new StoreDetails();
storeDetails.setStoreName(JSONRequest.getString("store_name"));
storeDetails.setInstagram(JSONRequest.getString("instagram"));
storeDetails.setTelegram(JSONRequest.getString("telegram"));
return storeDetails;
}
private boolean isNetworkAvailable() {
ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
boolean isAvailable = false;
if (networkInfo != null && networkInfo.isConnected()) {
isAvailable = true;
}
return isAvailable;
}
private void alertUserAboutError() {
AlertDialogFragment dialog = new AlertDialogFragment();
dialog.show(getFragmentManager(), "error_dialog");
}
This works for me. Use an stringrequest to put the post data to the request. After onResponse was called I create an JSON-Object from the string:
public void doServerRequest(final Context context, final String url, final Map<String,String> postParameters, final HashMap<String,String> getParameters, final OnFinishTaskListener<String, JSONObject> listener){
Log.d(TAG,"Start new server request (" + url + ")");
StringRequest request = new StringRequest(Request.Method.POST, addParametersToUrl(url, getParameters), new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.d(TAG, response);
try {
JSONObject json = new JSONObject(response);
if (json.getInt(CODE_TAG) == 0){
listener.getResult(SUCCESS_TAG, json);
} else {
listener.getResult(ERROR_TAG, null);
}
} catch (Exception e){
e.printStackTrace();
listener.getResult(ERROR_TAG, null);
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
listener.getResult(ERROR_TAG, null);
}
}) {
#Override
protected Map<String, String> getParams() throws AuthFailureError {
if(postParameters == null){
return new HashMap<String, String>();
}
return postParameters;
}
};
requestQueue.add(request);
}
This adds the get-Paramters to the URL (if exist):
private String addParametersToUrl(String url, HashMap<String,String> getParameters){
if(getParameters == null || getParameters.size() == 0){
return url;
}
Log.d(TAG,"Preparing URL: "+url);
StringBuilder stringBuilder = new StringBuilder(url);
stringBuilder.append("?");
int i = 0;
for (String key : getParameters.keySet()) {
if(i>0) stringBuilder.append("&");
stringBuilder.append(key).append("=").append(getParameters.get(key));
i++;
}
url = stringBuilder.toString();
Log.d(TAG,"Prepared URL: "+url);
return url;
}
I use this listener interface:
public interface OnFinishTaskListener<S,J> {
public void getResult(S string, J json);
}

Volley- fetching json array with POST request

I am using volley.jar to fetch JSON array from remote server. Am able to fetch via GET request.Please help me with POST request
I am following a tutorial from androidhive.
Here is my working code.
public class fbuk extends Activity {
// Movies json url
private static final String url = "http://example.com/xyz.php?q=ram";
private ProgressDialog pDialog;
private List<Movie> movieList = new ArrayList<Movie>();
private ListView listView;
private CustomListAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_main);
listView = (ListView) findViewById(R.id.listview);
adapter = new CustomListAdapter(this, movieList);
listView.setAdapter(adapter);
pDialog = new ProgressDialog(this);
// Showing progress dialog before making http request
pDialog.setMessage("Loading...");
pDialog.show();
JsonArrayRequest movieReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hidePDialog();
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
Movie movie = new Movie();
movie.setTitle(obj.getString("ttl"));
movie.setThumbnailUrl(obj.getString("img"));
movie.setRating(obj.getString("stts"));
movie.setYear(obj.getString("relz"));
movieList.add(movie);
} catch (JSONException e) {
e.printStackTrace();
}
}
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
});
// Adding request to request queue
AppController.getInstance().addToRequestQueue(movieReq);
}
#Override
public void onDestroy() {
super.onDestroy();
hidePDialog();
}
private void hidePDialog() {
if (pDialog != null) {
pDialog.dismiss();
pDialog = null;
}
}
}
How to send params
public void Post(String url, final Map<String, String> map) {
showProgress();
RequestQueue queue = Volley.newRequestQueue(_serverctx);
StringRequest request = new StringRequest(Method.POST, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
if (response!=null && response.length()>0) {
try {
_response.result(new JSONObject(response)); // Pass data to your parsing method(in my case i made a interface)
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
System.out.println("error");
hideProgres();
}
}){
#Override
protected Map<String, String> getParams() {
return map;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
request.setShouldCache(false);
request.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 1, 1.0f));
queue.add(request);
}
Call from Activity or fragment
Put the above method in a seprate class and give a call like
Map<String,String> params = new HashMap<String, String>();
params.put("email",email);
params.put("password",password);
_req = new NetworkRequests(this, ctx);
_req.Post(ShoqahContants.Login_URL, params);
and your are Done :)
This worked for me.
pDialog = new ProgressDialog(this);
pDialog.setMessage("Loading...");
pDialog.show();
url="http://www.example.com/xyz.php";
Volley.newRequestQueue(your_activity.this).add(
new CustomJsonRequest(Request.Method.POST, url, null,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
hidePDialog();
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
GC gc = new GC();
gc.setTitl(obj.getString("ttl"));
} catch (JSONException e) {
e.printStackTrace();
}
}
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Error: " + error.getMessage());
hidePDialog();
}
}) {
#Override
protected Response<JSONArray> parseNetworkResponse(
NetworkResponse response) {
try {
String jsonString = new String(response.data,
HttpHeaderParser
.parseCharset(response.headers));
return Response.success(new JSONArray(jsonString),
HttpHeaderParser
.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
} catch (JSONException je) {
return Response.error(new ParseError(je));
}
}
});
}
#Override
public void onDestroy() {
super.onDestroy();
hidePDialog();
}
private void hidePDialog() {
if (pDialog != null) {
pDialog.dismiss();
pDialog = null;
}
}
public class CustomJsonRequest extends Request {
Map<String, String> params;
private Response.Listener listener;
public CustomJsonRequest(int requestMethod, String url, Map<String, String> params,
Response.Listener responseListener, Response.ErrorListener errorListener) {
super(requestMethod, url, errorListener);
params=new HashMap<String, String>();
params.put("key", value);
this.params = params;
this.listener = responseListener;
}
#Override
protected void deliverResponse(Object response) {
listener.onResponse(response);
}
#Override
public Map<String, String> getParams() throws AuthFailureError {
return params;
}
#Override
protected Response parseNetworkResponse(NetworkResponse response) {
try {
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
return Response.success(new JSONObject(jsonString),
HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
} catch (JSONException je) {
return Response.error(new ParseError(je));
}
}
p.s:the json must be in the below format
[{"titl":"The Great gatsby"},{"titl":"Wolf Of Wall Street"}]

best way to send params in json array volley

I am using volley library to fetch json array via POST request. when I use get method am able to fetch the desired values but when I use POST method am unable to fetch any value instead am getting this error
value of type org.json.jsonobject cannot be converted to jsonarray
Here is my code
public class xyz extends Activity {
private static final String url = "http://example.com/q.php";
private ProgressDialog pDialog;
private List<Movie> movieList = new ArrayList<Movie>();
private ListView listView;
private CustomListAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_main);
listView = (ListView) findViewById(R.id.listview);
adapter = new CustomListAdapter(this, movieList);
listView.setAdapter(adapter);
pDialog = new ProgressDialog(this);
// Showing progress dialog before making http request
pDialog.setMessage("Loading...");
pDialog.show();
// changing action bar color
Response.ErrorListener errorListener = new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError errorResponce)
{
VolleyLog.d( "Error: " + errorResponce.getMessage());
hidePDialog();
}
};
Response.Listener<JSONArray > jsonArrayListener = new Response.Listener<JSONArray>()
{
#Override
public void onResponse(JSONArray response) {
// TODO Auto-generated method stub
hidePDialog();
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
Movie movie = new Movie();
movie.setTitle(obj.getString("ttl"));
movieList.add(movie);
} catch (JSONException e) {
e.printStackTrace();
}
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
};
Map<String, String> mParam = new HashMap<String, String>();
mParam.put("q", "ram");
PostJsonArrayRequest req = new PostJsonArrayRequest(Request.Method.POST, url , null, jsonArrayListener, errorListener,mParam);
// Creating volley request obj
// Adding request to request queue
AppController.getInstance().addToRequestQueue(req);
// Adding request to request queue
}
#Override
public void onDestroy() {
super.onDestroy();
hidePDialog();
}
private void hidePDialog() {
if (pDialog != null) {
pDialog.dismiss();
pDialog = null;
}
}
public class PostJsonArrayRequest extends JsonRequest<JSONArray> {
private Map<String,String> mParam;
private Response.Listener<JSONArray> mListener;
public PostJsonArrayRequest(int method, String url, String requestBody,
Response.Listener<JSONArray> listener, Response.ErrorListener errorListener,Map param) {
super(method, url, requestBody, listener, errorListener);
mListener=listener;
mParam=param;
}
#Override
protected Map<String, String> getParams() throws AuthFailureError {
return mParam;
}
#Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
try {
String jsonString =
new String(response.data, HttpHeaderParser.parseCharset(response.headers));
return Response.success(new JSONArray(jsonString),
HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
} catch (JSONException je) {
return Response.error(new ParseError(je));
}
}
#Override
protected void deliverResponse(JSONArray response) {
mListener.onResponse(response);
}
}
}
please guide me where am making the mistake. am i passing the params correctly?

Categories

Resources