我正在开发一个有 5 个接口的应用程序
我有一个活动,用户必须输入密码,输入密码后,用户移动到下一个活动,但是当用户单击后退按钮并返回密码活动时,输入的密码丢失了......怎么能我保持输入的密码?
代码:
back = (Button) findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v1) {
Intent backIntent = new Intent();
backIntent.setClass(getApplicationContext(), LockAppActivity.class);
backIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
startActivity(backIntent);
finish();
}
});
假设应用程序以活动 A --> B --> C --> D --> E 开始
当用户从 C 移动到 B 时,在活动 B 处有一个“停用”按钮,当用户按下它时,所有用户设置都会被清除,应用程序将退出,但是当我按下按钮时,它会将我带到布局C...我怎样才能改变这个?
deactivate = (Button) findViewById(R.id.deactivate);
deactivate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
final String STORAGE = "UniqueID_IMSI";
SharedPreferences unique = getSharedPreferences(STORAGE, 0);
SharedPreferences.Editor editor1 = unique.edit();
editor1.putString("identifier", "");
editor1.putString("simIMSI", "");
editor1.commit();
final String LOGIN_PASSWORD = "Login_Password";
SharedPreferences loginPassword = getSharedPreferences(LOGIN_PASSWORD, 0);
SharedPreferences.Editor editor2 = loginPassword.edit();
editor2.putString("loginPassword", "");
editor2.commit();
final String LOCK_APP_PASSWORD = "LockAppPassword";
SharedPreferences userPassword = getSharedPreferences(LOCK_APP_PASSWORD, 0);
SharedPreferences.Editor editor3 = userPassword.edit();
editor3.putString("password", "");
editor3.commit();
final String PHONE_NUMBER = "Phone_Number";
SharedPreferences phone = getSharedPreferences(PHONE_NUMBER, 0);
SharedPreferences.Editor editor4 = phone.edit();
editor4.putString("phoneNumber", "");
editor4.commit();
finish();
}
});
}