Android 如何通过截击传递整数值或双数值
我想使用getParams方法向服务器发送一个数值。服务器API需要整数值。服务器Api需要整数值,但我发送了一个字符串值 我的代码是:Android 如何通过截击传递整数值或双数值,android,get,android-volley,Android,Get,Android Volley,我想使用getParams方法向服务器发送一个数值。服务器API需要整数值。服务器Api需要整数值,但我发送了一个字符串值 我的代码是: StringRequest request = new StringRequest(Request.Method.GET, C.LOGIN_URL, response, errorListener) { protected Map<String,String> getParams() {
StringRequest request = new StringRequest(Request.Method.GET, C.LOGIN_URL, response, errorListener) {
protected Map<String,String> getParams() {
Map<String, String> map = new HashMap<>();
map.put("NCode", 123456);
map.put("Password", "abc12345");
return map;
}
};
C.addToQueue(request);
StringRequest request=newstringrequest(request.Method.GET、C.LOGIN\uURL、response、errorListener){
受保护的映射getParams(){
Map Map=newhashmap();
map.put(“NCode”,123456);
地图放置(“密码”,“abc12345”);
返回图;
}
};
C.addToQueue(请求);
我尝试使用String.valueOf,但我的服务器需要一个数值。当我将String和int作为正文的一部分发送时,这对我很有效
JSONObject jsonObject = new JSONObject();
jsonObject.put("NCode", 123456);
jsonObject.put("Password", "abc12345");
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, C.LOGIN_URL, jsonObject, response, errorListener){
//insert code here
};
C.add(request);