The launcher displays a label and icon for any recently resumed tasks. If your app package has multiple apps as separate launcher activities, the launcher doesn't know which label and icon to show for non-launcher activities, such as activities launched from a tile or a notification. This might cause your app to not show up in the Recents list in the launcher or to show up incorrectly.
Label all activities
Ensure that your activities, including non-launcher activities, are properly labelled in your manifest file, as shown in the following steps.
Figure 1. Examples of properly labeled activities.
- For every activity in your
AndroidManifest.xml
file, determine which launcher activity it belongs to. - Copy the icon, round icon, and label from the parent launcher activity into each associated non-launcher activity.
For activities that are shared among multiple launcher activities, decide which icon and label to display that represents all of them.
Assign RecentTasks
To use RecentTasks
for the Recents section in the launcher, ensure that your
taskAffinity
elements are correctly defined in your AndroidManifest.xml
file and
that you manage your tasks and back stack consistently.
Keep the following considerations in mind as you assign tasks:
- Choose a unique
taskAffinity
name for each task in your app. You can consider each launcher activity and its children as one task. Assign thattaskAffinity
to every related activity in your manifest file. - Avoid calling
startActivity()
withFLAG_ACTIVITY_NEW_TASK
orFLAG_ACTIVITY_CLEAR_TOP
. - Avoid creating trampoline activities, which are activities that only launch other activities. Create splash screens using the SplashScreen API.
- Use
android:excludeFromRecents="true"
andandroid:noHistory="true"
flags when you don’t want your activity to show up in the Recents section. - Determine the best launch mode for your activities and develop with that in mind.
Debugging tips
Look out for the following things when debugging:
- If there are double entries in the Recents section for a single app,
check whether you are using the
NEW_TASK
flag inappropriately. - If the wrong icon or label displays, ensure that each associated non-launcher activity has the same icon, round icon, and label as its parent activity.
- If the system doesn't launch anything after tapping the entry in the launcher, check Logcat (filtered on “launcher”) for errors, as this issue can be caused by a trampoline activity.
Recommended for you
- Note: link text is displayed when JavaScript is off
- Tasks and the back stack
- Create custom Quick Settings tiles for your app
- Learn Jetpack Navigation