I have an application that is already implemented. In this app. user can start any activity from any other activity.

What I want to do:

If the activity that asked to be launched is already exist in the history stack. that activity on the stack should be restarted and all the activities that exists before it in the stack should be finished.

ex: A->B->C->D->E->F
now we want to start D. A B C D should be finished and a new instance of D should be started keeping on the stack E->F->D

Thanks,