我收到一个错误,就像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);
}