0

I have an android app that's been on the market for a while that i'm now overhauling. I'm using the new One x for testing, and noticed some weird things...

  1. If i run the on my phone, click the home button so that the app goes to the background, i get the normal printouts i have in onPause etc. onDestroy does NOT get called, which makes you assume the process is still running.

  2. However, when i go into settings/apps/running, it's not listed!! What i DO get a reoccuring printout every few seconds in the android log as long as i'm on the "running" screen:

    06-20 15:04:42.435: INFO/RunningState(16694): Unknown non-service process: XXX #16558

  3. If i then click on my app icon again, My lifecycle methods are called as if my app wasn't started, i.e. onCreate, onResume etc. gets called again!!

I have no idea why this is, it doesn't happen on Galaxy2 or the Note, which i just tried, i get the "expected" lifecycle calls there.

Anybody got any thoughts? To me it looks like something is broken in the phone, but i'm just one guy and i haven't found any other reports, so i can't understand how that could be the case...

EDIT: also tested same code on the HTC Legend, no problems there...

Mathias
  • 3,879
  • 5
  • 36
  • 48

2 Answers2

2

There's no garantee that onDestroy will be called when you exit / finish an activity:

From http://developer.android.com/reference/android/app/Activity.html#onDestroy()

There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

Also see this thread here in SO

Activity OnDestroy never called?

Community
  • 1
  • 1
User
  • 31,811
  • 40
  • 131
  • 232
  • Hey, thanks for responding. I know this, naturally, however i find it very curious that i have never seen it myself in the wild before, yet it happens every time here. Furthermore, given the strange output from the "running apps" program, which indicates that something seems to still be running, i smell a rat... – Mathias Jun 20 '12 at 22:10
1

In Android ICS there are some new settings for developers, among them - "Don't keep activities". It is cleared by default, but your device might be configured in another way. Try switching this checkbox on/off and see what'd happen with your activity's lifecycle.

trashkalmar
  • 883
  • 5
  • 11
  • Thanks for pointing it out, didn't know about that setting. However, it wasnt checked. I did check it, and it then it behaved as advertised, i.e. my ondestroy, onpause-etc methods were called as i'd expect. I turned it off again, and i was back at the strange behaviour i have described. – Mathias Jun 20 '12 at 22:13