End the Android app on the HOME button

How to end the application on a click button HOME?

+3
source share
5 answers

You don’t have it - just let Android pause your application and clean it if necessary.

+5
source

You only have to complete the operation by detecting the click action and call finish () in the action.

+2
source

, .

Anywho: Home-Button .

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_HOME:
            finish();
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}
+2

, acitvity FLAG_ACTIVITY_NO_HISTORY, :

public static final int FLAG_ACTIVITY_NO_HISTORY

, . , . noHistory. : 1073741824 (0x40000000)

.

+2

Android . , "".

0

Source: https://habr.com/ru/post/1795217/


All Articles