What are the Fundamental Units of Android Application

Android applications are written in the Java programming language. The Android SDK tools compile the code—along with any data and resource files—into an Android package, an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application. Then this .apk file is run with delvik run time machine.

Fundamental Units of Android Application:

Following are four main android components.

  • Activity

An Activity represents the presentation layer of an Android application. A simplified description is that an Activity represents a screen in your Android application. This is slightly incorrect as Activities can be displayed as dialogs or can be transparent. In this case it would not fill the whole screen. Activity always run in foreground An one android application can have several Activities.
An activity represents a single screen with a user interface. For example, an login application might have one activity that ask you to enter username and password, another activity to show data related with user username.

  • Services

A service is one of the fundamental units of Android application that runs in the background to perform long-running operations. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application.

Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it. Services perform background tasks without providing a user interface. They can notify the user via the notification framework in Android. A service is implemented as a subclass of Service

  • Content providers

A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it).
Content providers are also useful for reading and writing data that is private to your application and not shared. For example, the Note Pad sample application uses a content provider to save notes. A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other applications to perform transactions.

  • Broadcast receivers

A broadcast receiver is a among fundamental units of Android application that is mostly used for notification purpose. Many messages originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcasts—for example, to let other applications know that status of particular activity is updated. Although broadcast receivers don’t display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a “gateway” to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event.

Broadcast Receiver can be registered to receive system messages and Intents. A Broadcast Receiver will get notified by the Android system, if the specified situation happens. For example a Broadcast Receiver could get called once the Android system completed the boot process or if a phone call is received.

Working with more than one fundamental units of Android application:

A unique aspect of the Android system design is that any application can start another application’s component. For example, if you want the user to capture a photo with the device camera, there’s probably another application that does that and your application can use it, instead of developing an activity to capture a photo yourself. You don’t need to incorporate or even link to the code from the camera application. Instead, you can simply start the activity in the camera application that captures a photo. When complete, the photo is even returned to your application so you can use it. To the user, it seems as if the camera is actually a part of your application.

Activating Components:

Three out of the four fundamental units of Android application types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime (you can think of them as the messengers that request an action from other components), whether the component belongs to your application or another.
Intents allow combining loosely coupled components to perform certain tasks. An intent is created with an Intent object, which defines a message to activate either a specific component or a specific type of component—an intent can be either explicit or implicit, respectively.

Intent intent = new Intent(this, DisplayMessageActivity.class); 
startActivity(intent);

The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from a ContentResolver. The content resolver handles all direct transactions with the content provider so that the component that’s performing transactions with the provider doesn’t need to and instead calls methods on the ContentResolver object.

There are separate methods for activating each type of fundamental units of Android application.

  • To start an foreground activity by passing an Intent to startActivity() .
  • To start a background running service by passing an Intent to startService().
  • To initiate a broadcast by passing an Intent to methods like sendBroadcast(), .
  • To retrive a data from or to query to a content provider by calling query() on a ContentResolver.

Full android web application Tutorial:-

Introduction How to develope Android application

Step by Step Installation guid for android application developent

How to Build and Run the Android Application

Views in Android Application

Linear Layout in Android Application Development

Table Layout in Android Application

Relative Layout in Android Application

SQLite Database used in Android Application Development

Music Player Code for Android Application Development

How to make Phone call for Android Application with full code

Status Bar in Android Application Development with Full Code


Leave A Reply

Your email address will not be published.