@Override public void success(LoginBean loginBean) { Toast.makeText(this, "登录成功", Toast.LENGTH_LONG).show(); SharedPreferences sp = getSharedPreferences("config", MODE_PRIVATE); sp.edit().putString("username",loginBean.getData().getUsername()) .putString("login","true").putInt("uid",loginBean.getData().getUid()) .putString("nickname",String.valueOf(loginBean.getData().getNickname())).commit(); finish(); }
取值
//第三方QQ登录的头像 iconurl = sp.getString("iconurl", null); imageLogin.setImageURI(iconurl); String nickname = sp.getString("nickname", null); //判断登录状态 login = sp.getString("login", ""); if (login.equals("true")) { txtLogin.setText(nickname); } else { txtLogin.setText("登录/注册>"); } //上传头像 String icon = sp.getString("icon", null); String replace = icon.replace("https", "http"); if (login.equals("true")){ imageLogin.setImageURI(replace); }else{ imageLogin.setImageResource(R.mipmap.user); }