Search this blog

Understanding Components of an Android Application

It is very important to understand the components of an android application because Your Android applications will be built from these four basic component types and these are discussed below:
Activities are pieces of executable code that come and go in time,instantiated by either the user or the operating system and running as long as they are needed. They can interact with the user and request  data or services from otheractivities or services via queries or Intents (discussed in a moment).Most of the executable code you write for Android will execute in the context of an Activity. Activities usually correspond to display screens: each
Activity shows one screen to the user. When it is not actively running, an Activity  can be killed by the operating system to conserve memory.
They are executable pieces of code that usually run in the background from the time of their instantiation until the mobile handset is shut down. They generally don’t expose a user interface.The classic example of a Service is an MP3 player.Your applicationmay need to implement Services to perform background tasks.
                                                         Broadcast and Intent Receivers
These respond to requests for service from another application. A Broadcast Receiver responds to a system-wide announcement of an event. These announcements can come from Android itself (e.g., battery low) or from any program running on the system. An Activity or Service provides other applications with access to its functionality by executing an Intent Receiver, a small piece of executable codethat responds to requests for data or services from other activities.
The requesting(client) activity issues an Intent, leaving it up to the Android framework to figureout which application should receive and act on it.Intents are one of the key architectural elements in Android that facilitate the creation of new applications from existing applications (mobile mashups). You will use Intents in your application to interact with other applications and services that provide information needed by your application
                                                                Content providers
These are created to share data with other activities or services. A content provideruses a standard interface in the form of a URI to fulfill requests for data from otherapplications that may not even know which content provider they are using. For example, when an application issues a query for Contact data, it addresses thequery to a URI of the form:content://contacts/peopleThe operating system looks to see which applications have registered themselves as content providers for the given URI, and sends the request to the appropriate application (starting the application if it is not already running). If there is morethan one content provider registered for the requested URI, the operating systemasks the user which one he wants to use.
Note: An application doesn’t have to use all of the Android components,but a well-writtenapplication will make use of the mechanisms provided, rather than reinventing functionalityor hardcoding references to other applications.


Post a Comment