我有以下
ImageView mImageView;
mTxtDisplay = (TextView) findViewById(R.id.txtDisplay);
String url = "http://my-json-feed";
String xSession = "";
JsonObjectRequest jsObjRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
/*
{
"message": "Session created",
"session": "d4f7d26799c720eb6b09daa97a1b7e64",
"result": {
"id": "331339814848696320",
"name": "Administrator",
"email": "cyz@jsjsjsjsjsjsjsjsjsj.com",
"username": "admin"
}
}
*/
xSession = response.getString("session");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
在响应上我可以看到response.getString(“session”)有值,但xSession没有填充? 为什么xSession没有被填充?请帮忙!
答案 0 :(得分:1)
Java语言区分大小写。你在哪里宣布xSession变量?那么,你要处理的正确的是xsession还是xSession?请查看或发布更相关的代码。
答案 1 :(得分:0)
尝试在onResponce
内记录回复。如果到达那里,那么确保xsession的值仅在收到响应后使用并且设置为