Is onCreate called when a class object that extends activity is created? Or is it only called when an activity is started, for example over startActivity(...).
i think that in Android , you cant write something like this :
AClassThatExtendedAnActivity instance = new AClassThatExtendedAnActivity();
the only way that you can use to launch an activity is passing with an intent to start your activity .
the creation of the instance is encapsulated on the super.onCreate(savedInstanceState);
when you override the method onCreate(Bundle savedInstanceState);
Regards ,
According to the developer.android.com the onCreate get called when activity is started. see details here
To answer you question, for a class that extends activity, if you try to instantiate that Activity by normal means ( MyActivity ma = new MyActivity(); ) the onCreate() method WILL NOT be called. Only if you start the Activity with an intent will the method be called.
Each activity in an application goes through its own lifecycle. Once and only once when an activity is created, is the onCreate() function executed.
Check this Activity Life Cycle