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
somewhere in Activity
or there is an hidden class that Activity
implements that contains main
.
I looked everywhere but couldn't find it. I would appreciate if any one could give a clear idea on it.
Android takes care of threading and keeping threads organized for you, see here. Moreover, the entry point for an activity is the onCreate() method, so all initialization is normally done in there. The first activity run by your app is normally specified in the manifest file under the launcher keyword.
Android Studio stores the projects by default in the home folder of the user under AndroidStudioProjects. The main directory contains configuration files for Android Studio and the Gradle build files. The application relevant files are contained in the app folder.
Android applications are broken down into four main components: activities, services, content providers, and broadcast receivers.
4 Answers. Show activity on this post. The first "entry" point is the application class as Kingston pointed out. However, the easiest thing to get the very first starting point is to check the stack when debugging onCreate.
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 (After android 5.0 DVM is replaced by Android Runtime) 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With