How does android:taskaffinity work?

4.5k Views Asked by At

How does android:taskaffinity attribute work?

As per my understanding, pressing the Home key will move the activity to back stack, but it will not be destroyed. I am confused.

1

There are 1 best solutions below

0
On

You indeed set a diffrent android:taskAffinity for activity2 and for the other activities. This will force android to make a diffrent stack when (see my example).

 <activity android:name=".activity2" android:taskAffinity="com.example.act2" >
 </activity>

 <activity android:name=".activity1" android:taskAffinity="com.example.act1" >
 </activity>

The following sequence should be correct. for the

  1. Start activity2.
  2. press Home
  3. Start activity1.
  4. Press back -> the homescreen should be showed.