0

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

Paul Boddington
  • 37,127
  • 10
  • 65
  • 116

1 Answers1

0

This is all about taskAffinity refer here for documentation. For more clarity, you can read this answer https://stackoverflow.com/a/17873524/403255

Community
  • 1
  • 1
Vinothkumar Arputharaj
  • 4,567
  • 4
  • 29
  • 36
  • Thank you. The answer you link to and especially the slideshow are really good. They explain in great detail the bafflingly complex rules for deciding if an intent will start the new activity in the same task as the sender or in a new one, and whether it will even create a new instance or be routed through onNewIntent() etc etc. But unless I'm missing something, they say nothing about why pressing the home button and then clicking on a launch icon often kills an activity. Surely clicking on a launch icon from the home screen should simply restore a task to its state before home was pressed? – Paul Boddington Aug 31 '14 at 15:30
  • Can you explain more in details about `clicking on a launch icon often kills an activity`? – Vinothkumar Arputharaj Sep 01 '14 at 03:31
  • Here is where I explain the issues I'm having in more detail. There's a bounty available for this! http://stackoverflow.com/q/25518197/3973077 – Paul Boddington Sep 01 '14 at 06:55