Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 302
hixhix Avatar asked Jan 19 '16 01:01

hixhix


People also ask

Can an app have multiple activities?

Most apps contain multiple screens, which means they comprise multiple activities. Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.

How do I change my recently used apps?

From the Home screen, tap the Recents icon to the left of the Home button. All of your active or opened apps will be listed. If you've customized your Navigation bar, Recents may be located on the right, unless you're using full screen gestures. To open an app, simply tap it.

What is activity stack?

A task is a collection of activities that users interact with when trying to do something in your app. These activities are arranged in a stack—the back stack—in the order in which each activity is opened. For example, an email app might have one activity to show a list of new messages.


1 Answers

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>
like image 173
JayWozz Avatar answered Oct 25 '22 07:10

JayWozz