Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is main() in Android?

Tags:

java

android

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.

like image 677
Basimalla Sebastin Avatar asked Feb 15 '12 12:02

Basimalla Sebastin


People also ask

Why there is no main method in Android?

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.

Where is the main file in Android Studio?

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.

Is main component an Android app?

Android applications are broken down into four main components: activities, services, content providers, and broadcast receivers.

What is the entry point of Android application?

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.


1 Answers

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.

like image 128
Chandra Sekhar Avatar answered Sep 24 '22 02:09

Chandra Sekhar