I use the following code in my application activity to prevent it from closing my application.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
}
return super.onKeyDown(keyCode, event);
}
This does not work. The application is configured for compatibility with Android 1.6 (API Level 4). Clicking on the icon of my application restarts my application in the active Splash mode (which is the main one). How can I prevent my application from closing?
source
share