An Android Application is composed of various components which are activity , service , broadcast receivers and content providers.
An Android activity contains the User Interface of an application.It enables user to interact with the application. Android user interface is one of the only reason for Android popularity. For example, If you are creating an chatting application:
- Login screen is the first activity on which user can access the further functionalities.
- Friend list is the second screen or second activity which enables user to do chat with the active user.
For more than one activity in the Application developer needs to register the launcher activity which he wanted to see first , like
Service is an application component which has no Graphical User Interface(GUI). It can perform long running operations in the background without any user interface. For example music player in android , whenever you play an music file and close the application it always runs in the background.
To declare a service file in AndroidManifest.xml
System generated notifications are termed as broadcast receiver. Broadcast receivers send the notification on the status bar to alert the user about the events. For example when the battery is low you got a notification that you battery is low etc.
Content provider is used to store and share the information among the application. Its empowers the UI to work with the data.
Building an Android application
Android Build process provides projects and module build setting so that our android application complied and packed to get .apk. Android build process process flow :
Creating an android Application
Creating an android application includes following steps :
Define the resources
Implement application classes
Install and Run Application
Define Resources :
Resources are the non-source code entities many difference resource types such as Layout ,Strings , Images , Menus and Animations. Resources allows app to customized for different devices and users.
We can categorized the resources into default and alternative resources. Default resources are those who belongs from device configuration and alternate resources are those which is manually configured apart from the device configuration.
Implement Classes :
Implementation of classes usually involves at leats one activity. Activity initialization code usually in onCreate. Now lets us see what's the flow of onCreate :
- Restore the saved state
- Set content View
- Initialise the UI elements
- Link UI element to code actions
Package the Application :
System package application components and resource into a .APK file. Developer specify required application information in a specified file name as AndroidManifest.xml.
Android Manifest file includes the all relevant information about the Application such as name , icon etc and required permission application feature and Minimum and maximum API level.
Install and Run :
From the eclipse framework run the application an Android application via Emulator or Device.Running through device you need to activate the USB debugging option from the Device setting.