Friday 30 January 2015

Android application key components

This tutorial explains some of the basic key components of an Android application, which will be helpful in creating an Android project.

Activities: An activity is a single screen in which a user interacts in an android application. An application can have more than one activity. When an application starts it calls the default activity mentioned in AndroidManifest.xml (Refer HelloWorld example in the previous blog) as highlighted below, this can be changed at any point of design time.
<activity
            android:name=".MainActivity"
            android:label="@string/app_name" >

An activity can call / start another activity when required.

Services: Service is the component that is used to perform action in the background for an application without any user interaction. It can used for logging or to perform work for remote process.  

Content Provider: It’s the standard interface to share data between processes and provide mechanism for defining data security. Used to store data in the file system or use SQL Lite. For example using the content provider the app can read and modify the contact details using the Android provided content provider.

Broadcast Services: It’s a way to listen to system wide even happening in your Android device which is accessible to all apps. Some of the Android provided broadcast services are Screen turned on, battery is low, call/SMS is received, phone is booted etc.

Intents: It’s a messaging object you can use to request an action from another component. An Intent is the key component to call one activity from another activity. For example from our app we can request camera app to take a picture.
Explicit Intent: Specify the component to start by name like call another activity in the same app.
Implicit Intent: Does not specify the component to start instead declare a general action to perform which allows a component from another app to handle that.

Fragments: Fragment is the section of the activity which represents the behavior or a portion of user interface in an activity. An activity can have more than one fragment. A fragment has its own life cycle which can be removed or added at any point when an activity is running.

Views: It’s the place where all the UI elements are being placed in the android application.

Layouts: Layout in Android describes how the UI should look in an activity. This can be declared in the UI XML and/or instantiate the layout at runtime. This can be customized as per required. There are various types of layouts like Linear, Relative, List, Grid etc.


Resources: Resource is a component of the Android application which is used to keep track of all the non-code assets of the application. Resources can be a XML file, images, audio files, etc. 

Please provide your comments below the blog.



No comments: