0

I can't find some informations about android application (not activities) lifecycle. My question is, how the application is working, when I treat it like a java programm - when it's initializing for example static objects. I'm adding a small graphic, that is showing my point of view - I'll be greatfull if someone could tell me, if I'm thinking correct :-)

enter image description here

remudada
  • 3,751
  • 2
  • 33
  • 60
Krystian
  • 2,221
  • 1
  • 26
  • 41
  • 2
    Static objects are initialized for the very first time when you access a class those static objects are member of. they are not all initialized at start of application – ata Aug 08 '14 at 07:45
  • 1
    Yup its correct. Android OS have to kill app or you have to make them null. – Manoj Aug 08 '14 at 07:49

1 Answers1

1

For the application lifecycle, as per Android API Guide:

By default, every app runs in its own Linux process. Android starts the process when any of the app's components need to be executed, then shuts down the process when it's no longer needed or when the system must recover memory for other apps.

For static objects, they are initialized only once and are initialized when the class (which they are member of) gets loaded by ClassLoader. They will remain in memory until the class is unloaded. To read more about it, check this SO question

For activities, they have a clear lifecycle.

Community
  • 1
  • 1
ata
  • 8,853
  • 8
  • 42
  • 68