2

From my research on the internet, I found that if my app process is killed by the system, next time the user goes back to it, the system will restore the activity stack. That is, any activity on top of the root activity remains there, but only the very top one is recreated. (see here)

I tested this by killing my process in monitor (ddms). I don't see activity stack restored. Only the root activity appears. So anything I'm missing here? What else do I need to implement for the stack to be restored?

I found the "persistableMode" attribute. Is that what I need? docs

Or the android:alwaysRetainTaskState? docs

Community
  • 1
  • 1
Shawn
  • 2,675
  • 3
  • 25
  • 48
  • Please add the relevant links (from your research) to the question. – Nir Alfasi Aug 01 '15 at 22:03
  • It's worth noting that the activity stack is *not* restored if the app is killed by a swipe from recents. In that case, it restarts from the launcher activity. – Kevin Krumwiede Aug 01 '15 at 23:42
  • Have you got a better understanding of this question? I have the same question but can't find a reasonable explanation. – yongsunCN Feb 23 '16 at 19:42
  • I'm using Appcelerator Titanium. I thought it's Titanium's mechanism that prevents the activity stack from restoring. I'm not sure. – Shawn Feb 23 '16 at 23:49

1 Answers1

3

mostly it depends on flag which was used to launch intents

for example

Intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

 /** 
 * If set, this activity will become the start of a new task on this
 * history stack.
 *
 * This flag is generally used by activities that want
 * to present a "launcher" style behavior: they give the user a list of
 * separate things that can be done, which otherwise run completely
 * independently of the activity launching them.
 */

for more info see API doc:

Tasks and Back Stack

see also:

ceph3us
  • 7,326
  • 3
  • 36
  • 43