Is onCreate called when an Activity object is created?

前端 未结 4 1959
庸人自扰
庸人自扰 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:19

    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.

提交回复
热议问题