gpt4 book ai didi

android - Volley : [355] NetworkDispatcher. processRequest : Unhandled exception java. lang.IllegalArgumentException

转载 作者:行者123 更新时间:2023-11-29 18:26:34 27 4
gpt4 key购买 nike

您好,我正在尝试运行以下代码将数据发布到在线 MySQL 数据库

    if (data.getCount() > 0) {
data.moveToFirst();
do {
save(orderId,client, data.getString(0),data.getString(3),String.valueOf(finalCost),data.getString(4),longitude,latitude,"_",progressDialog);
} while (data.moveToNext());
data.close();
mydb.clearCart();

private void save(final String orderId, final String client, final String prodid, final String Seller, final String amount, final String quantity, final double longi, final double lat, final String location, final ProgressDialog progressDialog) {
String URL_ORDER = "https://foodfuzz.co.ke/foodfuzzbackend/market/orders/order.php";
StringRequest orderStringRequest = new StringRequest(Request.Method.POST, URL_ORDER,
//android M

new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject orderObject = new JSONObject(response);
String orderSuccess = orderObject.getString("success");
if(orderSuccess.equals("1")){
pay.setVisibility(View.GONE);
progressDialog.dismiss();
Toast.makeText(CheckOutActivity.this,"Order Placed Successfully " , Toast.LENGTH_SHORT).show();
}else{
Logger.getLogger("Error",orderObject.getString("message"));
pay.setVisibility(View.GONE);
progressDialog.dismiss();
Toast.makeText(CheckOutActivity.this,"Order failed "+orderObject.getString("message") , Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
progressDialog.dismiss();
Toast.makeText(CheckOutActivity.this,"Unable to place order " + e.toString(), Toast.LENGTH_SHORT).show();
pay.setEnabled(true);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
error.printStackTrace();
Toast.makeText(CheckOutActivity.this,"Error placing order " + error.toString(), Toast.LENGTH_SHORT).show();
pay.setEnabled(true);
}
}){
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("orderId",orderId);
params.put("client", client);
params.put("name", prodid);
params.put("seller", Seller);
params.put("amount", amount);
params.put("quantity",quantity);
params.put("longitude",String.valueOf(longi));
params.put("latitude",String.valueOf(lat));
params.put("location",location);
return params;
}
};
RequestQueue orderRequestQueue = Volley.newRequestQueue(this);
orderRequestQueue.add(orderStringRequest);

}

数据来自 sqlite 数据库,该数据库正在正确检索它。当我在低于 26 的 Android 版本上运行此程序时,它可以正常工作,但在高于 26 的版本上运行时,出现以下错误

    2019-10-30 17:57:45.206 8589-8697/com.otemainc.foodfuzzapp E/Volley: [355] NetworkDispatcher.processRequest: Unhandled exception java.lang.IllegalArgumentException: Request#getParams() or Request#getPostParams() returned a map containing a null key or value: (client, null). All keys and values must be non-null.
java.lang.IllegalArgumentException: Request#getParams() or Request#getPostParams() returned a map containing a null key or value: (client, null). All keys and values must be non-null.
at com.android.volley.Request.encodeParameters(Request.java:478)
at com.android.volley.Request.getBody(Request.java:466)
at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:275)
at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:249)
at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:94)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:123)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:131)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)

我的代码是否需要更新一些内容才能适应新版本?如果是,那是什么?

最佳答案

它在堆栈跟踪中说

java.lang.IllegalArgumentException: Request#getParams() or Request#getPostParams() returned a map containing a null key or value: (client, null). All keys and values must be non-null.

protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("orderId",orderId);
params.put("client", client); // <<< HERE
params.put("name", prodid);
params.put("seller", Seller);
params.put("amount", amount);
params.put("quantity",quantity);
params.put("longitude",String.valueOf(longi));
params.put("latitude",String.valueOf(lat));
params.put("location",location);
return params;
}

您的 client 值为 null:params.put("client", client);

关于android - Volley : [355] NetworkDispatcher. processRequest : Unhandled exception java. lang.IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58628539/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com