Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving application in background on back button event

Tags:

android

Is it possible to move the app in background when we click on device back button in android?

background means application moves to screen(application) from where it launches ?

like image 556
Roll no1 Avatar asked May 05 '12 10:05

Roll no1


People also ask

What happens when app goes into background?

An app is running in the background when both the following conditions are satisfied: None of the app's activities are currently visible to the user. The app isn't running any foreground services that started while an activity from the app was visible to the user.


1 Answers

Try Using

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) 
{
    switch(keyCode)
    {
        case KeyEvent.KEYCODE_BACK:

            moveTaskToBack(true);

            return true;
    }
    return false;
}
like image 50
N.Droid Avatar answered Sep 21 '22 22:09

N.Droid