1
>  public  void makeJsonObjectRequest(Long s,Double lat, Double lon, int
> timezone) {
>         String urlJsonObj = "http://projet.dev.e-njaz.com/api/example/getPrayerTimes/" + s + "/" +
> lat + "/" + lon + "/" + timezone;
>         JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
>                 urlJsonObj, null, new Response.Listener<JSONObject>() {
>             @Override
>             public void onResponse(JSONObject response) {
>                 Log.d(TAG, response.toString());
>                 try {
>                     DateFormat i=new SimpleDateFormat("HH:mm");
>                     DateFormat o = new SimpleDateFormat("KK:mm a");
>                     prayertimes.setStr_asarr(response.toString());
>                     prayertimes.str_ishaa=o.format(i.parse(response.getString("6").toString()));
>                 } catch (JSONException e) {
>                     e.printStackTrace();
>                 } catch (ParseException e) {
>                     e.printStackTrace();
>                 }
>             }
> 
>         }, new Response.ErrorListener() {
>             @Override
>             public void onErrorResponse(VolleyError error) {
>                 VolleyLog.d(TAG, "Error: " + error.getMessage());
>                 Toast.makeText(getApplicationContext(),
>                         error.getMessage(), Toast.LENGTH_SHORT).show(); 
>             }
>         });
>         AppController.getInstance().addToRequestQueue(jsonObjReq);
>          
>     }

hello evrybody , i need to return the object payer times in the function onReponse can you help me please. when i change the type return of onReponse i have a error .

srowland
  • 1,625
  • 1
  • 12
  • 19

1 Answers1

1

You have to use 'callbacks' to return value from within volley. its a fairly complicated approach so i would suggest an alternative. you should just create a variable in the activity and set its value in onResponse and use that variable in whatever function you want.(you can even call that function from within onResponse).

if you still want to try returning a value then check this

If you didnt understand something leave it in the comments

Community
  • 1
  • 1
Shreyans
  • 1,043
  • 2
  • 14
  • 25