I have a weird error that I cant figure out how to fix . I have a video player - a simple videoview that plays a video. Now I ve implemented logic so that when the user presses the back button - it tells him to press the back button again to exit, and when he does it exits. But the problem is the first back press is not caught! I dont know what is causing this. I Press back once nothing happens, I press again and it shows me the toast that says "Please press back again to exit" and on pressing again it exits. The first one is not caught no matter what I do . This is the code for OnBackPressed()
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
super.onBackPressed();
finish();
}
else {
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this, "Please press the back button again to exit",
Toast.LENGTH_SHORT).show();
}
}