I read about taskaffinity and created a demo application with the following steps:
- AND
- B ===> taskaffinity, com.ando
- WITH
- D ===> taskaffinity, com.ando
- E
It is written that actions with the same task-secretness secretly open one instance of another.
So, I put the log onResume of each action to see the task id. If it creates one instance, then why doesn't it execute onResume of B when opening D and vice versa.
I read the developers site and other posts, but still have not figured out how to use taskaffinity and why use it, why shouldn't we use singleInstance instead?
manifest:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.danroid.taskaffinity.A"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.danroid.taskaffinity.B"
android:label="@string/app_name"
android:taskAffinity="@string/task_affinity" >
</activity>
<activity
android:name="com.example.danroid.taskaffinity.C"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.danroid.taskaffinity.D"
android:label="@string/app_name"
android:taskAffinity="@string/task_affinity" >
</activity>
<activity
android:name="com.example.danroid.taskaffinity.E"
android:label="@string/app_name" >
</activity>
</application>
source
share