简体   繁体   English

Android onResume打开特定活动

[英]Android onResume open specific activity

I need to do the following in my app, but I dont know is it possible? 我需要在我的应用程序中执行以下操作,但我不知道是否可能? If so can anyone tell me how can I do that? 如果是这样,谁能告诉我怎么能这样做?

I start the app - > First Actvity - >second activity(child)->third activity(second activity child) - and here ex. 我开始应用程序 - >第一次活动 - >第二次活动(孩子) - >第三次活动(第二次活动孩子) - 这里是ex。 I press home button and third goes to pause. 我按下主页按钮,然后第三个停止。 And now when I return to the app I need to return to the first activity not the same one. 现在,当我返回应用程序时,我需要返回第一个不同的活动。 Can anyone tell me how can I do this? 谁能告诉我怎么能这样做?

Set android:clearTaskOnlaunch="true" on the activity launched from the home screen. 在主屏幕上启动的活动上设置android:clearTaskOnlaunch =“true”

From developer.android.com: 来自developer.android.com:

"When the value is "true", every time users start the task again, they are brought to its root activity regardless of what they were last doing in the task and regardless of whether they used the Back or Home button to leave it. When the value is "false", the task may be cleared of activities in some situations (see the alwaysRetainTaskState attribute), but not always." “当值为”true“时,每次用户再次启动任务时,无论他们最后在任务中执行什么操作,他们都会进入其根活动,无论他们是使用”后退“还是”主页“按钮离开它。值为“false”,在某些情况下可以清除任务中的活动(请参阅alwaysRetainTaskState属性),但并非总是如此。“

Set this on the main activity ie. 在主要活动即设置此项。 the one launched from the home screen. 从主屏幕启动的那个。

Please look at the concept of Fragments. 请看一下Fragments的概念。 I have explained this idea in the following link . 我已在以下链接中解释了这个想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM