相关疑难解决方法(0)

Android系统.应用关闭后如何保存用户名和密码?

我正在编写一个包含登录详细信息(用户名和密码)的应用程序
我希望这样做,以便当用户关闭应用程序并稍后再次启动它时,他/她不必再次输入他/她的用户名和密码.

所以这是我的代码到目前为止.不幸的是,它似乎不记得密码和用户名:

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)

passwords user-interface android save

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

passwords ×1

save ×1

user-interface ×1