Execution Control Flow of an Android Application

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. inside onCreate 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.

 

Post By SmrutiRanjan (57 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon

Connect

One Response to Execution Control Flow of an Android Application

  1. restlessjai says:

    m working on a game on android.. i have a problem in resolving following code
    ((Activity)getContext()).finish();

    } else {

    Log.d(TAG, “Coords: x=” + event.getX() + “,y=” + event.getY());
    if u can help me out of it..i want to knw if activity can be resolved to a type..m working on eclipse juno

Leave a Reply

Your email address will not be published. Required fields are marked *


one × 3 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">