I'm getting an error like exception org.json.JSONexception
is never thrown in corresponding try block.
Whenever I try to remove the try catch block, the entire jsonobjectrequest()
function is getting thet error.
When I try to remove the jsonexception to exception it also giving me errors.
private void getdata() {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
// Toast.makeText(Live.this, response.toString(),Toast.LENGTH_SHORT).show();
tv.setText("Response => "+response.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
//add request to queue
queue.add(jsonObjectRequest);
}