How to change task affinity in Android?

3.3k Views Asked by At

There is an activity (A) in my application that can be called from other apps (B)

if A is called from B, in recent task there are an instance of B and an instance of A. i want that A be showen as part of B Task.

I've found that by adding same taskAffinity to both activities manifest file it works as i want. but i can't access B.

android:taskAffinity="xxx.yyy"

so, how do i find affinity of task B and change affinity of task A to it? OR is there a better way?

1

There are 1 best solutions below

0
On

Since FLAG_ACTIVITY_NEW_TASK is required for taskAffinity to take effect (that is, place activity A in a different task), start Activity A without using FLAG_ACTIVITY_NEW_TASK. I think this will cause activity A to be in the same task as activity B. This requires a change to B.