排球得到错误回应 [英] Volley getting an error response
本文介绍了排球得到错误回应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用凌空发送一些帖子数据。这是我的代码。这是后台服务的片段。如果您还想要其他文件,请告诉我。我已经添加了互联网许可。
I am sending some post data using volley. Here is my code . It's a snippet from background service. Let me know if you want other files also. I've added the internet permission.
public void onLocationChanged(final Location location) {
mCurrentLocation = location;
pref.setLocation(location);
String url = getResources().getString(R.string.hostname); // it's a normal http
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(getApplicationContext(), "Location sent", Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String errorMessage = "Err - data:"+error.getMessage();
Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_SHORT).show();
}
})
{
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put(KEY_USERID,pref.getUserId());
params.put(KEY_LAT,String.valueOf(location.getLatitude()));
params.put(KEY_LNG,String.valueOf(location.getLongitude()));
return params;
}
};
queue.add(stringRequest);
}
推荐答案
其实我看到了那个参数UserId具有Null值,这就是创建问题
Actually i saw that the one of the param UserId was having the Null value, That was creating the problem
这篇关于排球得到错误回应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文