我在运行此代码时面临Android Volley的问题,我在Android版本5.0.1上测试了这个工作正常,但在Android版本6.0.1上它存在
错误:E / Volley(22302):[15348] BasicNetwork.performRequest:
的意外响应代码500
https://site/OutletService.asmx/update_outlet
你对此有任何想法吗?非常感谢你的帮助。
Map<String, String> map = new HashMap<String, String>();
map.put(Constant.User.AccessKey, accessKey);
JSONArray jsonArray = new JSONArray();
jsonArray.put(toJSONObject());
map.put("Content-Type", "text/html; charset=utf-8");
//map.put(Constant.ListOutlet, String.valueOf(toJSONObject()));
map.put(Constant.ListOutlet, jsonArray.toString());
Log.i("SubmitData", map.toString());
ServerStringPostRequest submitRequest = new ServerStringPostRequest(map, ip + Constant.prefixtServerUpdateOutlet, new Listener<String>() {
@Override
public void onResponse(String responses) {
Log.i("Update", responses);
try {
JSONObject response = new JSONObject(responses);
String code = response.getString(Constant.code);
if (code.equals("1")) {
uploadImageForOutlet(context, ip, accessKey, callBack);
// callBack.onSuccess(OutLet.this);
} else if (code.equals("0")) {
callBack.onFail(OutLet.this);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
答案 0 :(得分:-1)
如果仅在Android 6中遇到问题。那么似乎是关于你的应用程序中的运行时权限的问题。因此,在运行时在java代码(Activity)中添加所有清单权限,如:
This is only for sample
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.INTERNET)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.INTERNET},
MY_PERMISSIONS_REQUEST_INTERNET);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
完整参考。看到这些链接