我收到的错误如exception org.json.JSONexception
从未在相应的try块中抛出
每当我尝试删除try catch块时,整个jsonobjectrequest()
函数都会出现错误
当我尝试删除jsonexception异常它也给我错误。
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);
}