I am trying getting data from an API using volley. I am trying to store it as a global variable, but it always returns null. Why?
Here is my sample code:
JsonObjectRequest jsonRequest = new JsonObjectRequest
(Request.Method.GET, url, null, response -> {
try {
if (response.getString("action").equals("success")) {
checkInTime = response.getString("checkin");
checkOutTime = response.getString("chekout");
System.out.println(response);
}
} catch (JSONException e) {
e.printStackTrace();
}
}, Throwable::printStackTrace);
Volley.newRequestQueue(MainActivity.this).add(jsonRequest);
What is the problem here?
here is my api json response
{"action":"success","checkin":"08:30:25","chekout":"blank"}
from Requested data cannot be store inside variable in Java
No comments:
Post a Comment