I'm trying to understand android tasks. Suppose you start an activity X from its launch icon and from that activity you start a new activity Y from a different application. You have a task consisting of the activities X and Y. Now suppose you press the home button and click on X's launch icon again. The android documentation says that by default the system should show the task as before with Y on top.
However with a bit of experimentation on a real device you find this isn't what happens a lot of the time. Suppose X is an email app and you view any content from an email in a different application Y (e.g. opening a photo in Gallery, opening a PDF document in Quickoffice, opening a web-page in Chrome etc) you will find that if you click home and then X's launch icon you in fact see X again. Sometimes the activity showing the content is moved to a different launch icon, but often it's just completely forgotten by the Android system as far as I can tell.
This is what happens if X is GMail, Yahoo Mail or Google Drive.
My question is what is causing Y to get thrown off the task? Is it something X does or something Y does? If it's something X does, is there anything you can do as the developer of Y to guard against it and stop your activity being forgotten by the android system? Thanks