Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

excludeFromRecents doesn't work with taskAffinity

Possible duplicate: How to not show app on recent apps list in ICS? excludeFromRecents doesn't work

Let's say I have two activities A (the main activity) and B. I start B from A as follows:

    Intent i = new Intent(A.this, B.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);

I want my app to have just one entry in the recents at any time AND B to be started at a new task. If B has a manifest entry as follows, I achieve that:

    <activity
        android:name="com.example.verysimpleactivity2.app.B"
        android:excludeFromRecents="true"
        android:label="B" ></activity>

But I also want B to have a different taskAffinity than the main activity, i.e. A. So I change the manifest entry into:

    <activity
        android:name="com.example.verysimpleactivity2.app.B"
        android:excludeFromRecents="true"
        android:taskAffinity=""
        android:label="B" ></activity>

In this case, if B is not in the foreground then it does not show up in the recents and I only have A (good!) However, if B is in the foreground and I press recents button, I see both A and B there. Why is B shown in the recents in this case? How to make sure I don't see B at all?

like image 886
kolistivra Avatar asked Mar 06 '14 15:03

kolistivra


1 Answers

Apparently, it is impossible to achieve what I want (at least in KitKat).

Source: an Android engineer

like image 143
kolistivra Avatar answered Oct 21 '22 03:10

kolistivra