字符串url = AppConfig.URL_IP +“?register = reg&first_name =” + fname +“&last_name =” + lname +“&email =” + email +“&address =” + address +“&password =” + password +“&number =” + number +“&city =” + city +“&category =” + category;
Log.d(“ urlll”,url);
StringRequest request = new StringRequest(Request.Method.GET,url,new Response.Listener (){
@Override
public void onResponse(String response){
尝试{
JSONObject jsonObject =新的JSONObject(response);
boolean checkerror = jsonObject.getBoolean(“ error”);
如果(checkerror){
字符串error_message = jsonObject.getString(“ error_msg”);
Toast.makeText(getApplicationContext(),error_message,Toast.LENGTH_SHORT).show();
}其他{
字符串sucess_message = jsonObject.getString(“ sucess_msg”);
Toast.makeText(getApplicationContext(),sucess_message,Toast.LENGTH_SHORT).show();
}
} catch(JSONException e){
e.printStackTrace();
}
}
},新的Response.ErrorListener(){
@Override
公共无效onErrorResponse(VolleyError错误){
Toast.makeText(getApplicationContext(),error.getMessage()+“ aaaa”,Toast.LENGTH_SHORT).show();
}
});
AppController.getInstance()。addToRequestQueue(request,“ registerAPI”);
它给了我这个错误:
W / System.err:org.json.JSONException:值<!-类型
java.lang.String无法转换为JSONObject
任何人都可以提前解决谢谢。