为什么Android不发出请求? (RequestQueue不起作用)

时间:2019-12-02 13:23:50

标签: java android request android-volley

我正在尝试使用httpsRequestQueue进行一个简单的Volley请求,但它只是不执行该请求。

代码附在下面:

RequestQueue queue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                // Display the first 500 characters of the response string.
                System.out.println("ggg:"+response);
                if (response.contains("HERE")) {
                    Toast.makeText(getApplicationContext(), "Logged in successfully!", Toast.LENGTH_LONG).show();
                    Intent in = new Intent(getApplicationContext(), ImportContactsActivity.class);
                    startActivity(in);
                } else if (response.contains("OK")) {
                    Toast.makeText(getApplicationContext(), "Not", Toast.LENGTH_LONG).show();

                } else if (response.contains("logoff")) {
                    Toast.makeText(getApplicationContext(), "Please log off your old device to login.", Toast.LENGTH_LONG).show();
                }
            }
        }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        //sSystem.out.println("bla: "+error);
    }
});
queue.add(stringRequest);

0 个答案:

没有答案