如何退出应用程序并显示主屏幕? [英] How to exit from the application and show the home screen?

查看:262
本文介绍了如何退出应用程序并显示主屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,在主页上有用于浏览该应用程序的按钮.

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 take the user to the home screen on the phone where the application icon is.

我该怎么做?

推荐答案

Android的设计不支持选择退出应用程序,而是通过OS对其进行管理.您可以通过相应的Intent调出Home应用程序:

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);

这篇关于如何退出应用程序并显示主屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆