java – How to put an Android app in the background?

Question:

I'm starting to work with Android Studio and I'm having doubts.

My problem is the following:

I have an application that has a "Splashscreen" or presentation screen and it works as a launcher for it. After a few seconds jump to another activity to login.

When this second screen (login) is presented, I would like that when pressing the back button,

 @Override public void onBackPressed() {}

and through this action send the application to the background.

It is the same behavior that the vast majority of applications present, so I suppose that there will be some method to solve it easily.

All the best.

Answer:

Most applications terminate the Activity via finish() , and you see a shortcut to access it again.

In the case you comment you can use

moveTaskToBack(true);

Which moves the task containing this Activity to the bottom of the Activities stack.

@Override
    public void onBackPressed() {
        moveTaskToBack(true);
    }
Scroll to Top