EDITED & SOVLED (below)
I need to make a kind of last-check when the user is leaving the Activity.
If the result of this check is unsuccess, I need to not allow him to go out.
I need a kind of this:
@Override
protected void onPause() {
if (comprobations == true){
super.onPause();
} else {
NOT EXIT!!
}
}
It seems easy :p but I tried and don't runs.
Anyone can help me?
Thaanks
SOLUTION:
Thanks to all of you for the quick answers!
Every of them helped me and I have learned some new things.
I have tried the onBackPressed()
method, this is what I was looking for.
I know that the user is still able to exit from the App by pressing the Home button and some another ways, but I just want to prevent users to think the configuration of my App is ok when they go back to the main menu; if they wish to go out from the App, it's ok.
So I will do something as this:
@Override
public void onBackPressed() {
Log.d(LOGTAG, "onBackPressed");
if (COMPROBATIONS() == true){
super.onBackPressed();
} else {
SHOW WARNING!
}
return;
}
Thanks to everybody fo your help.
Have a nice time.