Learning Android – Part 2: The Manifest file, Activity stack, and Layout

· Tech · , ,

The Manifest file

The Manifest file is an XML file used to store general information about the application. In the Manifest file you store information such as; declaring the application’s components (see Part 1 if you don’t know the different components), determine app settings like name and version, identifying user permissions (internet access, contact list), minimum API level, declaring hardware and software features it uses (GPS, camera, bluetooth etc), and API libraries it uses. The Manifest file stores also the Intent-filters. The way the system identifies the components that can respond to an intent is by comparing the Intent received to the Intent-filters provided in the Manifest. Example of an Manifest file: click here!

Activity Stack

The Android operating system keeps track of all activities which are on a Activity Stack. When a new Activity starts the Activity on top of the stack gets paused and the new one is pushed on. When the Activity on top is removed the previous Activity is resumed. To start an Activity you use the method called startActivity(new Intent(getApplicationContext()),MyActivity.class). The Intent object in this context is called an “anonymous Intent object”.


onCreate(Bundle i):

called when Activity starts. The Bundle keeps information about previous state (example: saving game state). It is here you set the main layout of the Activity (using the method setContentView()).


called when the Activity resumes (the Activity on top is removed)


called when another Activity moves on top of the stack.


the Activity has completed is life cycle (shut down by itself) or Android killed it.


Each Activity has has it’s own graphical layout which is stored under the folder “res/layout”. The Layout is an XML file which defines the different UI elements it uses. An Activity sets its Layout by using the method “setContentView(R.layout.main)”. Android uses an reference system where you access the different resources by using the class R  – resources such as the layout, the different UI elements, images, and other resource data.  Each UI element in the Layout file has an Android id which is defined using the attribute “android:id=@+id/name_of_the_element”. The UI element can then be accessed using the R class (“R.id.name_of_the_element”). When accessing the UI element inside the Java code, the method “findViewById(android id)” is used.

Written by almirmesic · · Tech · , ,
NextLearning Android - Part 1: Intro and The four components