I want to block TouchEvent if I posted an alertbox, indeed I can press the screen and I can acces to a screen that is protected by a password. how then protect access to the screen as if my password is true. My dialogbox is given by the code below:
void showDialog() {
final String myPassword = getResources().getString(R.string.password);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.connection);
// Set an EditText view to get user input
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
String hashedPassword = Utilities.md5(value);
if (myPassword.equalsIgnoreCase(hashedPassword)) {
//code
} else {
Toast.makeText(getApplicationContext(),
"Mot de passe incorrect", Toast.LENGTH_LONG).show();
admin = false;
Intent intent = getIntent();
finish();
startActivity(intent);
}
}
});
alert.setNegativeButton("Annuler",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
Intent intent = getIntent();
finish();
startActivity(intent);
}
});
alert.show();
}