android Volley登录验证的使用

    xiaoxiao2021-12-10  8

    使用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(); }

    转载请注明原文地址: https://ju.6miu.com/read-700390.html

    最新回复(0)