Is onCreate called when an Activity object is created?

前端 未结 4 1957
庸人自扰
庸人自扰 2020-12-14 22:45

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(...).

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 23:06

    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 ,

提交回复
热议问题