Basics components in Android applications


Before getting started with android programming, we need to know some of the basic components of Android applications. These are the buildings blocks of Android applications. These will let us understand Android application from scratch. Let us take a quick look at these components.

                An activity in Android represents a single screen with user interface. An android application typically consists of several activities.  An activity interacts with the user to do one thing, only ONE, such as Unlock screen, dial a phone, view home etc. An application consists of multiple activities that are loosely bound together. But only one activity can be specified as main activity which is displayed while launching the application. Every time an activity starts previous activity is stopped but the data is preserved.
         For instance an email application will have one activity to display list of new emails, another activity to compose email, another activity for reading emails and so on.

Have a look at activities in detail here

             An activity contains views and viewgroups. Views in Andriod are UI components that could be used to build user interface. Examples are buttons, label, and text boxes. One or more views can be grouped together into a ViewGroup. Types of View in android.
  • ·         Basic Views
  • ·         List Views
  • ·         Picker Views
  • ·         Menus
  • ·         Display Views
  • ·         Additional Views
ViewGroup provides a layout where you can order the appearance of views. Android support the following view groups.
  •           LinearLayout
  • ·         TableLayout
  • ·         AbsoluteLayout
  • ·         FrameLayout
  • ·         RelativeLayout
  • ·         ScrollView
                Services are something that does not require user interface. It performs operation without user interaction in the background but does not get initiated without user invocation. Another component such as an activity should invoke. To be more technical, service does not have an independent thread, they make use of the main thread from hosting process. For instance you can download something while you get involved in some other application, where download is a service running in background.

Content Providers
                Android is embedded with SQLite Database where all your data gets stored. Content providers in Android manage data that is being shared by more than one application. Consider a case where your Contacts are stored in centralized repository, so here many applications may require access to it or may even require modifying it. In such cases these applications need to query the centralized repository through content providers, so an application with proper permissions can read or modify the Contacts based on permissions. Content provider is concept evolved to manage common data based on permissions. This is a critical concept that has led to develop in-house android applications in a better way.

Broadcast Receivers
                Broadcast receiver is also a component where you can register for system or application events. Once registered you will be notified about the events. Broadcast originates from the system as well as applications. Instance for broadcast originating from the system is ‘low battery notification’. Application level is, like when you download an mp3 file, Mp3 player gets notified about it, and gets added to player list. For this action to take place, mp3 player has to register for this event. To get detailed information on Broadcast receiver in Android, have a look at this tutorial

                Intents are messages that allow components to request activities from other components. Consider an activity requires another activity to perform some functionality in such cases communication between activities occurs via Intent.

I believe these will help you to develop applications with a clear understanding. Please post your views. 

Write comments
  1. Good this is must for better programming.

  2. The Description Is Good and I am Expecting Explanation Along With Some Code.

    Thank You

  3. This is really very helpful i like your brief view of explanation keep going.

  4. Yeah, It is very helpfull n must known for the programmers to better code.

  5. Its very nice to understand the concepts


Popular Posts