简体   繁体   中英

how to keep multiple activities of the same app in the recent-apps list

I have one app with two activities A & B, both with launch mode singleInstance. I notice that even if both A and B are running in the background, only the last activity is shown in recent-apps list. Is it possible to keep both A & B in the recent-apps list? Thanks.

In the AndroidManifest, make sure to set the android:taskAffinity attribute of the element differently for each Activity. For example:

<activity
    android:name="com.example.ActivityA"
    android:label="Activity A"
    android:launchMode="singleInstance"
    android:taskAffinity="com.example.AffinityA" >
</activity>
<activity
    android:name="com.example.ActivityB"
    android:label="Activity B"
    android:launchMode="singleInstance"
    android:taskAffinity="com.example.AffinityB" >
</activity>

诀窍是通过启用FLAG_ACTIVITY_NEW_TASK标志的Intent启动新Activity。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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