我在将 JSON 对象的值分配给局部变量时遇到问题,调试器显示变量 = 'this' 不可用
I got an issue with assign value from JSON Object to Local Variable , Debugger Shows variable = 'this' is not Available
The first time it is working fine , after some testing I got this
problem.
i cant get value from Json Object
, the Json Array
is fine , but
value not assinged.
我正在使用 Andorid Studio
,Volley
用于从 Json Format
中的 Web 服务器获取响应。
StringRequest postRequest = new StringRequest(StringRequest.Method.POST, syncURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
long TempResponse = response.length();
if (TempResponse <= 2){
udo_Core.udfShowMessage("Error","Error In Getting Data From Server!",udo_temp_activity);
}else {
JSONArray arr = new JSONArray(response);
for (int i = 0; i < arr.length(); i++) {
JSONObject mJsonObject = arr.getJSONObject(i);
try{
udo_entry_max_BAR = mJsonObject.getLong("maxentryno");
udo_entry_min_BAR = mJsonObject.getLong("minentryno");
udo_entry_no_BAR = udo_entry_min_BAR;
udo_entry_no_MAX = udo_entry_max_BAR;
}catch (Exception e){
e.printStackTrace();
}
//udo_PRB_Limit = 100/(udo_entry_max_BAR-udo_entry_min_BAR);
}
}
}catch (JSONException e){
e.printStackTrace();
}
}
},
new Response.ErrorListener()
{ @Override
public void onErrorResponse(VolleyError error){
error.printStackTrace();
}
}
){
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("query", udoQuery);
params.put("type", type);
params.put("companycode", "");
params.put("p_fm_loc", "");
params.put("p_to_loc", "");
params.put("p_fm_date", "");
params.put("p_to_date", "");
return params;
}
};
postRequest.setRetryPolicy(new DefaultRetryPolicy(12000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
udoVolleyQuery.add(postRequest);
while Debugging , inside the loop assign value from Json Object to
Local variable but In Debugger window shows " udo_entry_max_BAR =
'this' is not Available "
这只在调试器中显示Window,执行完成后你会得到值。
The first time it is working fine , after some testing I got this problem.
i cant get value from
Json Object
, theJson Array
is fine , but value not assinged.
我正在使用 Andorid Studio
,Volley
用于从 Json Format
中的 Web 服务器获取响应。
StringRequest postRequest = new StringRequest(StringRequest.Method.POST, syncURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
long TempResponse = response.length();
if (TempResponse <= 2){
udo_Core.udfShowMessage("Error","Error In Getting Data From Server!",udo_temp_activity);
}else {
JSONArray arr = new JSONArray(response);
for (int i = 0; i < arr.length(); i++) {
JSONObject mJsonObject = arr.getJSONObject(i);
try{
udo_entry_max_BAR = mJsonObject.getLong("maxentryno");
udo_entry_min_BAR = mJsonObject.getLong("minentryno");
udo_entry_no_BAR = udo_entry_min_BAR;
udo_entry_no_MAX = udo_entry_max_BAR;
}catch (Exception e){
e.printStackTrace();
}
//udo_PRB_Limit = 100/(udo_entry_max_BAR-udo_entry_min_BAR);
}
}
}catch (JSONException e){
e.printStackTrace();
}
}
},
new Response.ErrorListener()
{ @Override
public void onErrorResponse(VolleyError error){
error.printStackTrace();
}
}
){
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("query", udoQuery);
params.put("type", type);
params.put("companycode", "");
params.put("p_fm_loc", "");
params.put("p_to_loc", "");
params.put("p_fm_date", "");
params.put("p_to_date", "");
return params;
}
};
postRequest.setRetryPolicy(new DefaultRetryPolicy(12000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
udoVolleyQuery.add(postRequest);
while Debugging , inside the loop assign value from Json Object to Local variable but In Debugger window shows " udo_entry_max_BAR = 'this' is not Available "
这只在调试器中显示Window,执行完成后你会得到值。