on Login button click, i want to reset the password from "0000" to current dateformat, even after restart of application pswd should be dateformat

huangapple go评论55阅读模式
英文:

on Login button click, i want to reset the password from "0000" to current dateformat, even after restart of application pswd should be dateformat

问题

我是你的中文翻译,以下是已翻译好的代码部分:

private EditText Name;
private EditText Password;
private Button Login;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    PermissionTest();
    LoginButton();
}

public void PermissionTest() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
        ;
    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 10);
}

public void LoginButton() {
    Name = (EditText) findViewById(R.id.etName);
    Password = (EditText) findViewById(R.id.etPassword);
    Login = (Button) findViewById(R.id.btnLogin);

    Login.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(Name.getText().toString().equals("admin") && Password.getText().toString().equals("0000")) {
                        Intent intent = new Intent(LoginActivity.this, PageActivity.class);
                        startActivity(intent);
                    }else {
                        Toast.makeText(LoginActivity.this, "USER NAME AND PASSWORD INCORRECT", Toast.LENGTH_SHORT).show();
                    }
                }
            }
    );
}

如果你还有其他需要翻译的部分,请继续提供。

英文:

what I mean is, i want to give the application to a user with password as "0000", after it's first use the password need to reset automatically to date format. so that the user cannot enter to the application with password "0000". Is there any way to code like this?

after login, the default password need to change to some other password (preferably date format)

I am hereby attaching the current status - java class code, pls help

private EditText Name;
private EditText Password;
private Button Login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
PermissionTest();
LoginButton();
}
public void PermissionTest() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
;
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 10);
}
public void LoginButton() {
Name = (EditText) findViewById(R.id.etName);
Password = (EditText) findViewById(R.id.etPassword);
Login = (Button) findViewById(R.id.btnLogin);
Login.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if(Name.getText().toString().equals("admin") && Password.getText().toString().equals("0000")) {
Intent intent = new Intent(LoginActivity.this, PageActivity.class);
startActivity(intent);
}else {
Toast.makeText(LoginActivity.this, "USER NAME AND PASSWORD INCORRECT", Toast.LENGTH_SHORT).show();
}
}
}
);
}

答案1

得分: 1

第一次运行您的应用程序时,在sharepreference中放入0000。成功登录后,从sharepreference中删除它,并替换为新密码。

英文:

First time your app runs, put 0000 in sharepreference. After successful login delete it from sharepreference and substitute new password in it.

huangapple
  • 本文由 发表于 2020年10月5日 02:58:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64198683.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定