Home » Android » android – How to return to home screen from Activity

android – How to return to home screen from Activity

Posted by: admin June 15, 2020 Leave a comment

Questions:

I know Android will return to the home screen when I press the Home key, however,
I want my imageButton to behave as the Home key, which can inform the home screen to the foreground.

How should I implement my onClickListener to accomplish this?

How to&Answers:
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    startActivity(intent);