How to exit from the application and show the home screen?

后端 未结 20 2306
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 09:45

I have an application where on the home page I have buttons for navigation through the application.

On that page I have a button \"EXIT\" which when clicked should t

20条回答
  •  深忆病人
    2020-11-22 10:08

    Android's design does not favor exiting an application by choice, but rather manages it by the OS. You can bring up the Home application by its corresponding Intent:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    

提交回复
热议问题