[英]Start last open Activity in android after pressing App icon
I have the following constellation: 我有以下星座:
Press App Icon open Activity A , which checks which activity should open next (Registration or Main Activity B ). 按“应用程序图标”,打开“ 活动A” ,该活动将检查接下来应打开的活动(“注册”或“主要活动B” )。 A is marked as Main Launcher in the xml.
在xml中将A标记为Main Launcher。 Now I go to B .
现在我去B。 Then I have a user action and come to Activity C .
然后,我有一个用户操作,然后进入活动C。 Now I press home.
现在我按回家。 If I chose the app again from background task selector i come back to C .
如果我再次从后台任务选择器中选择了该应用程序,则返回C。 But when I instead press the app icon again,I will start again with A .
但是,当我再次按下应用程序图标时,我将从A重新开始。 Is it possible to handle it in manifest that in this case C should open again or do I have to care it by myself (eg via SharedPreferences?)
是否可以在清单C中重新处理这种情况下进行处理,还是我必须自己照顾一下(例如,通过SharedPreferences?)
This behavior can be controlled in the manifest
via android:launchMode
. 可以通过
android:launchMode
在manifest
控制此行为。
See here: https://developer.android.com/guide/topics/manifest/activity-element.html#lmode and more explanation here: https://developer.android.com/guide/components/tasks-and-back-stack.html 参见此处: https : //developer.android.com/guide/topics/manifest/activity-element.html#lmode,以及此处的更多说明: https : //developer.android.com/guide/components/tasks-and-back -stack.html
for your scenario, you'd want to keep C and route new intents to the existing instance of it, so this might work: 对于您的方案,您需要保留C并将新的intent路由到它的现有实例,因此这可能有效:
<activity
android:name="A"
...
android:launchMode="singleTask" />
<activity
android:name="B"
...
android:launchMode="singleTask" />
<activity
android:name="C"
...
android:launchMode="singleTask" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.