如何完成所有活动并关闭android中的应用程序? [英] how to finish all activities and close the application in android?
本文介绍了如何完成所有活动并关闭android中的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序具有以下流程:
My application has the following flow:
主页->屏幕1->屏幕2->屏幕3->屏幕4->屏幕5>主页->屏幕2->主页->屏幕3
Home->screen 1->screen 2->screen 3->screen 4->screen 5>Home->screen 2->Home->Screen 3
我的问题是,当我尝试关闭应用程序时,每次我尝试关闭应用程序时都会打开Home活动.
My problem is that when I am trying to close the application then Home activity opens everytime when I am trying to close the application.
我只想在用户按下主屏幕上的设备的后退键时关闭应用程序.
I just want to close the application when user presses the back key of device on home screen.
推荐答案
有 finishAffinity()方法将完成当前活动和所有父活动,但仅在Android 4.1或更高版本中有效.
There is finishAffinity() method that will finish the current activity and all parent activities, but it works only in Android 4.1 or higher.
这篇关于如何完成所有活动并关闭android中的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文