使用Volley登录验证需要在Volley请求中验证登录和返回相关消息
//远程验证用户 private void removeVerify(){ String url = "http://192.168.80.2:8080/fag/login"; DataOfString json = new DataOfString(getApplicationContext(),url, Request.Method.POST,loginPojo.class); json.setVolleyCallBck(new StringVolleyCallback() { @Override public void getStringFromVolley(String s) { //System.out.println(s); } @Override public void putStringFromVolley(Map<String, String> map) { map.put(USERNAME,userName.getText().toString()); map.put(PASSWORDS,passWord.getText().toString()); } @Override public void getJsonFromJsonString(Object o) { loginPojo pojo = (loginPojo) o; if (pojo.getError_code() == 0){ //保存sessionId BaseApplication.setSessionId(pojo.getSessionId()); //保存用户信息 userinfo info = pojo.getData(); if (info != null){ // setuserinfo(); Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT).show(); } }else { Toast.makeText(getApplicationContext(), pojo.getReason(), Toast.LENGTH_LONG).show(); } } @Override public void getJsonErrorResponse(String s) { } }); json.StringFromAndPutNet(); } //保存用户相关信息 private void setuserinfo(){ //设置登录状态 BaseApplication.setApp_isLogin(true); finish(); }