在AndroidManifest.xml文件中指定主要启动器活动,并将其标记为默认活动。代码示例:
然后,重写主要活动的onBackPressed()方法,使其在打开HOME类别应用程序时返回到默认主屏幕。代码示例:
@Override public void onBackPressed() { if (isTaskRoot()) { // If this activity is the root activity of the task, // move the task to the back of the activity stack. moveTaskToBack(true); } else { // Otherwise, use the default back button behavior. super.onBackPressed(); } }