I am having three modules - ModuleA, ModuleB, ModuleC
ModuleA - 1 activity
MainActivity - no task affinity
Module B - 3 activities
Activity_A task affinity = "com.performance.poc.main"
Activity_B task affinity = "com.performance.poc.main"
Activity_C task affinity = "com.performance.poc.main"
Module C - 1 activity
Activity_D - no task affinity
Navigation Case 1:
- MainActivity
- on btn Click - start Activity_A Intent.FLAG_ACTIVITY_NEW_TASK
- on btn Click - start Activity_B
- on btn Click - start Activity_C
on btn Click - start Activity_D Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
Expected Task Result:
Task com.performance.poc
Activity_D
MainActivityTask com.performance.poc.main
Activity_C
Activity_B
Activity_AExpected : on starting the Activity_D task com.performance.poc.main should be cleared. Actual : Still Activity_A, Activity_B, Activity_C remains but MainActivity is cleared.
Navigation Case 2:
- MainActivity
- on btn Click - start Activity_A Intent.FLAG_ACTIVITY_NEW_TASK
- on btn Click - start Activity_B
- on btn Click - start Activity_C Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
- on btn Click - start Activity_D Intent.FLAG_ACTIVITY_NEW_TASK
Expected Task Result:
Task com.performance.poc
Activity_D
MainActivity
Task com.performance.poc.main
Activity_C
Activity_B
Activity_A
Expected : on starting the Activity_C, in task com.performance.poc.main, Activity_A, Activity_B should be cleared.
Actual : Activity_A, Activity_B is cleared as expected.
My Question here is why in Case1, even though Activity_A, Activity_B, Activity_C are in same task and it is not clearing these and clearing MainActivity.
The Clear_Task should clear the existing task of the activity from which startActivity is called with intent new_task and clear_task. or it will clear the task of target activity.
If it is Target activity, I need to clear the task of the leaving activity, is there any way to do it?