我最近开始使用Android开发平台。我正在使用Android Studio,并使用Volley库进行网络操作。我已经实现了iOS的推送通知的后端,它运行得很好,现在我通过Volley网络操作触发这个php,如下所示。
由于某些原因,它多次调用该URL(5或6次),我怎么知道?因为iOS设备收到多个通知。我不确定为什么会这样,我怎么能解决它?
public void onClick(View v) {
if(v == buttonBuy) {
message = (EditText) findViewById(R.id.offerText);
buy();
}
}
private void buy()
{
StringRequest postRequest = new StringRequest(Request.Method.POST, Config.ASK_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
} catch (Exception 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<>();
params.put("token",token);
params.put("pname",objee.optString("pname"));
params.put("toid",objee.optString("uid"));
params.put("pid",pid);
params.put("message",message.getText().toString().trim());
return params;
}
};
CustomVolleyRequest.getInstance(this).getRequestQueue().add(postRequest);
}
答案 0 :(得分:0)
尝试添加以下代码:
Compiling study_rust v0.0.1 (main.rs)
src/main.rs:45:17: 45:19 error: borrowed value does not live long enough
src/main.rs:45 myFunctor= &fx ;
^~
src/main.rs:44:36: 47:2 note: reference must be valid for the block suffix following statement 0 at 44:35...
src/main.rs:44 let myFunctor: &Fn(i32) -> i32;
src/main.rs:45 myFunctor= &fx ;
src/main.rs:46
src/main.rs:47 }
src/main.rs:45:5: 45:21 note: ...but borrowed value is only valid for the statement at 45:4
src/main.rs:45 myFunctor= &fx ;
^~~~~~~~~~~~~~~~
src/main.rs:45:5: 45:21 help: consider using a `let` binding to increase its lifetime
src/main.rs:45 myFunctor= &fx ;
^~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `study_rust`.