Where is main() in Android?

后端 未结 8 1482
南笙
南笙 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 01:02

    You tell it which one to run on startup in the manifest file. There isn't a main() function because there doesn't have to be. main() may be a convention used for "regular" java apps, but it isn't for things like browser applets. The system creates the activity object and calls methods within it, which may or may not be called main. In this case, it's not.

    onCreate is different from a main() method, and from a constructor, in that it can be called twice on a single activity, such as if the process is killed and the user navigates back to the activity. See this

    Many things that you might think of as a Java "application" do not have their own main() method. For example, IIRC, servlets, WARs, and the like do not have main() methods -- the main() method, if there is one, is in the container.

    0 讨论(0)
  • 2020-11-30 01:13
    onCreate() Method....See lifecycle of android class (Activity).....
    

    http://developer.android.com/reference/android/app/Activity.html

    0 讨论(0)
提交回复
热议问题