我正在编写一个包含登录详细信息(用户名和密码)的应用程序
我希望这样做,以便当用户关闭应用程序并稍后再次启动它时,他/她不必再次输入他/她的用户名和密码.
所以这是我的代码到目前为止.不幸的是,它似乎不记得密码和用户名:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mPrefs = getSharedPreferences(PREFS, 0);
final CheckBox rememberMeCbx = (CheckBox)findViewById(R.id.saveLoginCheckBox);
boolean rememberMe = mPrefs.getBoolean("rememberMe", false);
if (android.os.Build.VERSION.SDK_INT > 9)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
mXmlRpcClient = new XMLRPCClient(mXmlRpcUri);
// Set up the login form.
//mUsername = getIntent().getStringExtra(EXTRA_EMAIL);
mUsernameView = (EditText) findViewById(R.id.username);
mUsernameView.setText(mUsername);
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id,
KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) { …Run Code Online (Sandbox Code Playgroud)