我有一個輸入密碼對話框,它是Theme.Dialog主題中的一個活動,所以它看起來像AlertDialog,因爲我必須在廣播接收器中使用它,但問題是我想阻止HOME按鈕因爲我需要它的安全應用,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);
}
http://stackoverflow.com/questions/6836869/android-how-to-control-the-home-button?rq=1? – t0mm13b 2012-07-29 00:45:46
我見過有人在做你正在尋找的一個例子。希望能幫助到你! http://stackoverflow.com/a/6530002/1559836 – Mintrus 2012-07-29 00:46:22
這是指的是一些「幻像」Java源* DisableAllKey.java *,誰回答提到的人.... – t0mm13b 2012-07-29 00:49:40