我有一个输入密码对话框,它是 Theme.Dialog 主题中的一个活动,所以它实际上看起来像一个 AlertDialog,因为我必须在广播接收器中使用它,但问题是我想阻止 HOME 按钮,因为我需要它安全应用程序,当我使用它时阻止 HOME 按钮起作用
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
但是如果单击按钮后密码错误,它不会重新启动我的 PasswordDialog 活动,有什么建议吗?
验证码:
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
password = inputPassword.getText().toString();
final String SHA1hash = PhysicalTheftPassword.getSHA1(password);
if (correctSHA1.equals(SHA1hash)) {
//SharedPreferences sp = getSharedPreferences("isPhysicalTheftEnabled", MODE_WORLD_READABLE);
//SharedPreferences.Editor ed = sp.edit();
//ed.putBoolean("isPhysicalTheftEnabled", false);
//ed.commit();
Toast.makeText(PhysicalTheftDialog.this, "Correct", Toast.LENGTH_LONG).show();
finish();
stopService(new Intent(PhysicalTheftDialog.this, MyService.class));
Log.v(TAG, "SHA1 Hash:" + SHA1hash);
Log.v(TAG, "Correct SHA1:" + correctSHA1);
}
else {
Toast.makeText(PhysicalTheftDialog.this, "Wrong", Toast.LENGTH_LONG).show();
Intent Act2Intent = new Intent(PhysicalTheftDialog.this, PhysicalTheftDialog.class);
finish();
startActivity(Act2Intent);
Log.v(TAG, "SHA1 Hash:" + SHA1hash);
Log.v(TAG, "Correct SHA1:" + correctSHA1);
}