Android JSONObject响应为空

Android JSONObject响应为空,android,json,android-volley,response,Android,Json,Android Volley,Response,我正在尝试使用Volley-JsonObjectRequest发送一个简单的JSON请求。 在获得JSON响应之后,我想更新一个名为valoreConvertito的值,但是JSON响应为null,因此valoreConvertito保持为零 private void convertiREST(final Double valoreDaConvertire, String valuta){ final TextView textView = (TextView) findViewByI

我正在尝试使用
Volley-JsonObjectRequest
发送一个简单的
JSON请求。
在获得
JSON响应
之后,我想更新一个名为
valoreConvertito
的值,但是JSON响应为
null
,因此
valoreConvertito
保持为零

private void convertiREST(final Double valoreDaConvertire, String valuta){

    final TextView textView = (TextView) findViewById(R.id.text);
    RequestQueue queue = Volley.newRequestQueue(this);
    String url =COMPLETEURL;

    valoreConvertito = 0.0;

    JsonObjectRequest objectRequest = new JsonObjectRequest(
            Request.Method.GET,
            url,
            null,
            new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        try {
                            Log.e("Rest response    ", response.toString());
                            valoreConvertito = response.getJSONObject("quotes").getDouble("valuta");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e("Rest response", error.toString());
                    }
                });
        queue.add(objectRequest);
    }
private void convertiREST(最终双从价税,字符串值){
最终文本视图文本视图=(文本视图)findViewById(R.id.text);
RequestQueue=Volley.newRequestQueue(this);
字符串url=COMPLETEURL;
从价换算=0.0;
JSONObjectRequestObjectRequest=新的JsonObjectRequest(
Request.Method.GET,
网址,
无效的
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
Log.e(“Rest响应”,response.toString());
valoreConvertito=response.getJSONObject(“报价”).getDouble(“valuta”);
}捕获(JSONException e){
e、 printStackTrace();
}
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
Log.e(“Rest响应”,error.toString());
}
});
添加(objectRequest);
}
我甚至遵循了另一篇文章()中的建议,但JSON响应仍然为空


使用调试器,在添加行
队列后,程序似乎既不在
onResponse中输入,也不在
ErrorListener
中输入
我在Logcat中注意到
HTTP流量不允许
错误,我已经在帖子后面解决了我的问题。

在添加行
队列之后。添加(objectRequest)
我在Logcat中注意到
HTTP通信不允许
错误,我已在帖子后解决了我的问题。

您将请求添加到队列的位置?使用行“queue.add(objectRequest);“您将请求添加到队列的位置?使用行“queue.add(objectRequest);”编辑问题