Jamie, are you doing Android now? What a terrible thought! In any case, finish() is your friend when it comes to removing actions from the stack. You can call it several times to pull several actions from the stack.
Alternatively, you can also delete the entire stack by passing the FLAG_ACTIVITY_CLEAR_TOP flag in your intent (but it looks like you want to keep H, so this might not be a smart choice).
By the way, one thing I haven't played with is FLAG_ACTIVITY_NEW_TASK, but that might work in your case. Pass it on before starting A This can be completely useless in your case, so just experiment a bit with it.
EDIT: played around a bit with it, causing completion () several times, actually not working properly. I got it to work by running H with FLAG_ACTIVITY_CLEAR_TOP, and then Y right after that (i.e. Two startActivity in one function).
source share