json - How can I return the JSONArray response using the function below? -


i need jsonarray response returned can use in other functions inside mainactivity. how can return jsonarray response function below?

i have tried other ways such declaring public variable , storing response in doesn't seem work.

private void makejsonarrayrequest(string urljsonarry) {     showpdialog();      jsonarrayrequest req = new jsonarrayrequest(urljsonarry,             new response.listener<jsonarray>()             {                 @override                 public void onresponse(jsonarray response)                 {                     log.d(tag, response.tostring());                      try {                         // parsing json array response                         // loop through each json object                         string jsonresponse = "";                         (int = 0; < response.length(); i++)                         {                              jsonobject food_item = (jsonobject) response.get(i);                              string id = food_item.getstring("r_id");                             string name = food_item.getstring("r_name");                             string address = food_item.getstring("r_address");                             double latitude = food_item.getdouble("r_latitude");                             double longitude = food_item.getdouble("r_longitude");                             string contact = food_item.getstring("r_contact");                             string category = food_item.getstring("r_category");                             string website = food_item.getstring("r_website");                              latlng new_food_place = new latlng(latitude, longitude);                             marker marker = mmap.addmarker(new markeroptions().position(new_food_place).title(name));                             /*mmap.movecamera(cameraupdatefactory.newlatlng(sydney));*/                              mmarkers_food.add(marker);                               jsonresponse += "r_id: " + id + "\n\n";                             jsonresponse += "r_name: " + name + "\n\n";                             jsonresponse += "r_address: " + address + "\n\n";                             jsonresponse += "r_latitude: " + latitude + "\n\n\n";                             jsonresponse += "r_longitude: " + longitude + "\n\n\n";                             jsonresponse += "r_contact: " + contact + "\n\n\n";                             jsonresponse += "r_category: " + category + "\n\n\n";                             jsonresponse += "r_website: " + website + "\n\n\n";                              log.e("response" , "response: "+ jsonresponse);                         }                          mmarkers_food.size();                       } catch (jsonexception e) {                         e.printstacktrace();                         toast.maketext(getapplicationcontext(),                                 "error: " + e.getmessage(),                                 toast.length_long).show();                     }                      hidepdialog();                 }             }, new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {             volleylog.d(tag, "error: " + error.getmessage());             toast.maketext(getapplicationcontext(),                     error.getmessage(), toast.length_short).show();             hidepdialog();         }     });      // adding request request queue     appcontroller.getinstance().addtorequestqueue(req); } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -