I have a screen saver that leads to the main navigation screen, which has animations to enter buttons. I want me to close the application when the back button is pressed. It currently reloads activity (main) when the return button is called - why is this?
I looked at the forums, and one way was to use the finish () method. I tried to implement this in the main.java class as follows:
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if( keyCode == KeyEvent.KEYCODE_BACK )
{
this.finish();
return true;
}
return false;
}
But it wasn’t higher - what am I doing wrong?
Greetings
UPDATE
Greets everyone for a quick response, but none of these works. But I think I know why - my class only implements the onCreate () method, and no one else. Maybe that's why all other methods fail?
UPDATE
. , , , :
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ( keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 )
{
moveTaskToBack( true );
return true;
}
return super.onKeyDown(keyCode, event);
}
, finish(), onBackPressed(), ekawas, ?