杀死所有的活动时,HOME键是pressed机器人有的、机器人、HOME、pressed

2023-09-13 00:27:37 作者:心念人

我有一个应用程序,它在it.Within应用程序,历史活动,即从哪里导航不应该破坏活动4活动,所以我不叫光洁度()时,我导航。

I have an app which has 4 activities in it.Within app, history activities, i.e. Activities from where I navigated should not be destroyed , so I don't call finish() when I am navigating.

但是,当我preSS HOME按钮,我要杀死所有的活动,所以,当我回来的应用程序,索引画面或者说第一个活动显示,而不是previous暂停活动。

But when I press HOME button I want to kill all activities , So that When I come back to the app , Index screen or say first activity is displayed instead of previous paused activity.

这里的问题似乎是,如何在一个应用程序来HOME按键背区分。

Problem here seems to be, how to differentiate between backs within an app to HOME button.

我看到了其他的问题就这样几个答案。得到了更多的困惑。 有没有一种方式比拦截Home键$ P $干燥综合征等,因为在其他线程建议, 我不应该重写HOME键preSS(因为它可能有副作用)

I saw few answers regarding this in other questions. Got more confused. Is there a way other than intercepting HOME KEY PRESS, because as suggested in other threads, I should not override HOME key press (as it might have side effects)

推荐答案

设置android:clearTaskOnlaunch="true"从主屏幕上推出的活动。

Set android:clearTaskOnlaunch="true" on the activity launched from the home screen.

您可能还检查了一些其他属性,你可以在指定的活动,调整它的行为多一点。

You might also check some of the other attributes you can specify on activity, to tweak it's behavior a bit more.