我做了一个聊天应用程序,其中我必须将数据发布到我的服务器问题来自用户关闭应用程序数据发送但未在应用程序中更新我尝试使用粘性服务但在应用程序关闭它重新启动服务
我想更新ui甚至应用已关闭
StringRequest sr = new StringRequest(Method.POST,"-----", new Response.Listener<String>() {
@Override
public void onResponse(String res) {
//update UI data is post
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//error occured due to some prblm
}
}){
protected Map<String,String> getParams(){
Map<String,String> Newobj = new HashMap<String, String>();
Newobj.put("reciever","tymtupx");
return Newobj;
}
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/x-www-form-urlencoded");
return params;
}
};
sr.setRetryPolicy(new DefaultRetryPolicy(
0,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
AppController.getInstance().addToRequestQueue(sr);