Android studio 没有收到截击的任何回应
我几乎没有得到任何回应 这是一个学校的项目,我没有收到任何来自截击的回应,请帮助 我尝试过不同版本的截击,我尝试过在清单中添加互联网接入,没有任何帮助Android studio 没有收到截击的任何回应,android-studio,android-volley,Android Studio,Android Volley,我几乎没有得到任何回应 这是一个学校的项目,我没有收到任何来自截击的回应,请帮助 我尝试过不同版本的截击,我尝试过在清单中添加互联网接入,没有任何帮助 RequestQueue queue = Volley.newRequestQueue(this); api(); public void api(){ String new_url = "http://api.myjson.com/bins/kp9wz";
RequestQueue queue = Volley.newRequestQueue(this);
api();
public void api(){
String new_url = "http://api.myjson.com/bins/kp9wz";
System.out.println(new_url);
final JsonObjectRequest request = new
JsonObjectRequest(Request.Method.GET, new_url, null, new
Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("employees");
devices = new ArrayList<>();
for(int i = 0; i < jsonArray.length(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
String deviceId = jsonObject.getString("firstname");
String deviceName = jsonObject.getString("age");
String deviceStatus = jsonObject.getString("mail");
System.out.println(jsonObject.getString("firstname"));
System.out.println(jsonObject.getString("age"));
System.out.println(jsonObject.getString("mail"));
devices.add(new
Device(deviceName,deviceStatus,deviceId));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
System.out.println("WTF");
}
});
}
´´´
I don't get anything
I expect it to save the data into the arraylist and sout, each field in the for loop
RequestQueue queue=Volley.newRequestQueue(this);
api();
公共空api(){
字符串new_url=”http://api.myjson.com/bins/kp9wz";
System.out.println(新的url);
最终JsonObjectRequest请求=新建
JsonObjectRequest(Request.Method.GET,new_url,null,new
Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
JSONArray JSONArray=response.getJSONArray(“员工”);
设备=新的ArrayList();
for(int i=0;i
我太愚蠢了,没有将请求发送到请求队列,我已经解决了它