英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论