相关疑难解决方法(0)

Android Volley error.getMessage()为空

所以我正在为我的服务器创建一个POST JSonObjectRequest,当它成功时一切正常并且信息被发布,但是如果有错误并且我尝试在吐司中显示它,它会显示为空白.这是我的要求:

private void logUserIn() {
    final String URL = Globals.BASE_URL +"/auth/login/";
    // Post params to be sent to the server
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("username", username.getText().toString());
    params.put("password", password.getText().toString());

    JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(params),
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        Log.d("Log In User", response.toString());

                        //logged in db, changes screens
                        Intent nextScreen = new Intent(getApplicationContext(), MyProfile.class);
                        startActivity(nextScreen);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
        @Override
        public …
Run Code Online (Sandbox Code Playgroud)

android android-volley

14
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

android-volley ×1