1

In Android when you hold down the home button you can bring up a task list of your recent apps. And each "card" in the task list should have a preview of the app. However, this time I opened the task list and the previews were blank (except for the app title).

I had the phone Settings in the task list and every time I would tap on the task and try to open it in would close immediately.

I also had this app I was developing and when I tapped on the task to open the app my RecyclerView wasn't showing anything, when it should be.

I also was playing AngryBirds 2, so was it that Android had silently killed those apps for memory? If so, does onCreate() of the killed apps get called again when this happens?

Edit: I just noticed if you close an app too quickly when it's transitioning to an Activity you can get a blank preview.

Edit 2: So to answer my question, after referencing the Activity lifecycle diagram this is what I found. When another application needs memory, the app's process will be killed and when the user navigates back to the app, onCreate() will be called again. However, that doesn't explain why I couldn't reopen the Settings. And I have no idea how to reproduce this weird behavior!

mco
  • 1,809
  • 15
  • 31

1 Answers1

0

Ok after some debugging, I found out that Android did indeed kill my app because it needed memory. When you resume to your app however, onCreate will be called with a savedInstanceState that is NOT null. I had some logic that required savedInstanceState to be null and therefore my RecyclerView wasn't populated.

To recreate this scenario of Android killing my app I had to open a ton of apps lol. Is there way I can reproduce Android killing my app without opening all those apps? Hm...

mco
  • 1,809
  • 15
  • 31