I try to override this method and stuck with some problem
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if(screenStatus >=1)
{screenStatus=0;
indexMenu();
}
if(screenStatus==0)
{
finish();
}return false;
}
return super.onKeyDown(keyCode, event);
}
when i press on backbutton my app closed.. but if see on code.. there must be call function indexMenu(); i mean i have menu ... press some one from menu (start for example.. ) and have new window.. there i press on back button and i see how app return to main menu (indexMenu() ) and than closed (1 second after returning to indexMenu())
Can any tell me how to fix this ?
Regards,Peter
similar problem i found here Back button and last activity but i don't need alertBuilder.. and not need other message on the screen.. just want to back to indexMenu() without problem.
UPD AFTER HELP ok after help this code work perfectly for me :
@Override
public void onBackPressed()
{
if (screenStatus>=1)
{
indexMenu();
screenStatus=0;
// super.onBackPressed();
}
else if(screenStatus==0)
{
finish();
super.onBackPressed();
}
}
Thanks to : lordl , PKeidel
I made it this way and it works fine:
@Override
public void onBackPressed()
{
if (youWantToCloseTheApp)
super.onBackPressed();
else
// Do other funny things here
}