如何使用volley将stringrequest发送到特定的ip地址和端口而不是url?
我的代码目前看起来像这样:
public void onURLPassed(final String urlOfWebsite) {
Log.d(TAG, "Url passed: " + urlOfWebsite);
String tag_json_obj = "json_obj_req";
String serverURL = "http://test.me/api/request/page";
StringRequest jsonObjReq = new StringRequest(Request.Method.POST,
serverURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, response);
String parsedResponse = parse(response);
if (parsedResponse.equals("Error: This is not a valid website")) {
if (isViewAttached()) {
getView().displayMessage("This is not a valid website");
} else {
// error handling
}
return;
}
parsedResponse = parsedResponse.replace("\\" + "n", " \n");
parsedResponse = parsedResponse.replace("\\" + "\"", "\"");
getView().displayWebsite(parsedResponse.substring(1, parsedResponse.length()-1));
}
}, new Response.ErrorListener() {
我现在要做的是发送相同的POST请求,例如12.123.12.123:40而不是serverURL http://test.me/api/request/page
我将如何做到这一点?