In my app's settings, I have a checkbox that disables the back button when checked. I'm using SharedPreferences for that. but the problem is even when it's true, it changes to false when it's being checked in if-statement.
Boolean isLockedB;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
isLockedB = sharedPreferences.getBoolean("block_back",false);
when I debug, it shows the isLockedB value as true, then in here:
@Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(Gravity.RIGHT)){
drawerLayout.closeDrawer(Gravity.RIGHT);
}else {
if (isLockedB == false){
super.onBackPressed();
}else {
return;
}
}
}
it shows that my isLockedB is false.
Aucun commentaire:
Enregistrer un commentaire