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
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.
onCreate() Method....See lifecycle of android class (Activity).....
http://developer.android.com/reference/android/app/Activity.html