1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| EditText passw = (EditText)findViewById(R.id.editText);
String passwf = passw.getText().toString();
SharedPreferences sharedPreferences = MainActivity.this.getSharedPreferences("appSharedPreferences", Context.MODE_PRIVATE);
String userPassword = sharedPreferences.getString("userPassword", null);
if(userPassword == null){
if( passwf.equals("0000"))
{
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
}
else
{ Toast.makeText(MainActivity.this, R.string.erreur,Toast.LENGTH_LONG).show();
}
// Aucun mot de passe n'a été défini
}
else{
if( passwf.equals(userPassword))
{
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
}
else
{ Toast.makeText(MainActivity.this, R.string.erreur,Toast.LENGTH_LONG).show();
}
// Le mot de passe a été défini. Sa valeur est stockée dans userPassword
} |
Partager