Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity not visible in Recents when app is in background

Issue description

In one of my apps I am seeing quite odd behaviour: when my app is running in foreground (is top-most one), then I can see its activities in system's Recents. But as soon as I put it into background, the same activity (i.e. AccountsActivity) that was listed moments ago is no longer present in Recents. Related portion of my Manifest file:

<application
    android:name=".WebnetApplication"
    android:allowBackup="false"
    android:allowClearUserData="true"
    android:hardwareAccelerated="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".StartActivity"
        android:alwaysRetainTaskState="true"
        android:excludeFromRecents="true"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoDisplay" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".AccountsActivity"
        android:excludeFromRecents="false"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize" />

    ...

Findings

Since this is the only app of mine that misbehaves that way, I checked all styles, and my WebnetActivity and WebnetApplication to ensure I do not call anything that could influence Recents. There's nothing like this.

Then I started to strip down Manifest file to see if something would change. And as expected, the culprit lurks there, still it's no really clear for me why. At start, AccountsActivity entry in Manifest had no android:excludeFromRecents entry at all - this resulted in AccountsActivity being not visible in Recents at all. When I added android:excludeFromRecents="true" then the activity becomes visible in Recents, but only when it was in front. When I moved to back, then it disappeared from Recents. When I remove android:excludeFromRecents="true" from StartActivity declaration, then AccountsActivity become visible in Recents regardless app is in front or in background and I can remove android:excludeFromRecents from its entry completely without any problems as well.

Question

At the moment I am bending my head trying to understand why it all behaves that way - is it normal (and I do not know something) or it is perhaps rather bug in framework? Anyone faced similar issue and can share experience, ideas or explanation?

like image 438
Marcin Orlowski Avatar asked Jun 26 '14 17:06

Marcin Orlowski


1 Answers

Remove android:excludeFromRecents="true" from main activity.

Quote from android:excludeFromRecents:

Whether or not the task initiated by this activity should be excluded from the list of recently used applications ("recent apps"). That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set "true" if the task should be excluded from the list; set "false" if it should be included. The default value is "false".

like image 126
Elaman Avatar answered Sep 21 '22 05:09

Elaman