Where is main() in Android?

后端 未结 8 1518
南笙
南笙 2020-11-30 00:20

I am new to Android, and was studying the framework and it compelled me to ask this question. Since we are extending Activity in Android, there has to be main s

8条回答
  •  一向
    一向 (楼主)
    2020-11-30 00:55

    In core Java programs we need a main() method, because while executing the byte code the JVM will search for the main() method in the class and start executing there.

    In the case of Android, the Dalvik Virtual Machine is designed to find a class which is a subclass of Activity and which is set as a LAUNCHER to start the execution of the application from its onCreate() method, so there is no need of a main() method.

    For more information see the life cycle of Activity.

提交回复
热议问题