Execution Control Flow of an Android Application

Posted By on March 23, 2016


Download PDF
Directory Structure of an Android Application
Start New Activity Example

As a beginner we need to know the complete execution control flow of an Android application. To understand the basic execution flow of an Android application, Lets take the  HelloWorld example for detailed explanation.

When we create a new Android project using eclipse, We can see some folders such as “src” ,”gen” , “Android 2.2″ , “assets” and “res” etc.

To understand android flow lets start with the “res” folder. Inside the “res” folder there is a file called “AndroidManifest.xml“.
You can see code like below in your AndroidManifest.xml file.

In the Above xml file, we can find an entry called “HelloWordApp” listed inside the activity xml tag. This tag contains the Activity Name (First GUI screen of your application), which will be launch when you start your application. If you have multiple activity in your application then you must have to add entries for  all of your activity in AndroidManifest.xml file.

You need to add your activity name in the application’s menifest file (AndroidManifest.xml ) . Lets say if your activity name (Java Class Name of your Activity) is Xyz, Then you have to add the tag like <activity android:name=”.Xyz”></activity>.

In the our case (above example), We have the Activity Name called HelloWorldApp. Which is nothing but the Java class of your application. Hence we use  <activity android:name=”.HelloWorldApp“></activity>. Make sure you specify “.” (dot) before each activity when you add your activity entry in the manifest file.
In our example, Our activity name is “.HelloWorldApp”, which will call the HelloWorldApp.Java file for further execution. Also you can add the complete package name instead of .Activity name like(com.test.helloworld.HelloWorldApp) in the manifest file.

When HelloWorldApp Activity is created by default onCreate method will be executed. insideonCreate Method we have an setContentView which execute the android application design file whose name is main.xml because we have R.layout.main as an argument.

In Brief AndroidManifest.xml file execute the Launcher Activity class and from the launcher activity onCreate method will execute the Design View file by using setContentView method.

Directory Structure of an Android Application
Start New Activity Example

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com