excludeFromRecents doesn't work with taskAffinity
Asked Answered
S

2

9

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?

Solanaceous answered 6/3, 2014 at 15:13 Comment(0)
S
1

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

Source: an Android engineer

Solanaceous answered 6/3, 2014 at 18:33 Comment(2)
Can you please add more info? Why is it not possible?Cerenkov
I don't know why -- my personal guess would be due to security. I just know that it's not possible (as far as an Android engineer from Google told me)Solanaceous
R
0

A bit late but also adding the answer from androidManifest activity android:excludeFromRecents works. Just in case anyone else was having the same issue and though it couldn't work.

Rosenthal answered 13/12, 2014 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.