Sunday, May 20, 2012

APPLICATION CONTROLS AND PROGRAMME CONTROLS



            Application components are the essential building block of Android application. Each one is a different point through which the system can enter your application. Not all components are actual entry points for the user and some depend on each other, but each one exists as its own entity and plays a specific role- each one is a unique building block that help define your application’s behavior.
            The four important components are
  • Activity - represents the presentation layer of an Android application, e.g. a screen which the user sees. An Android application can have several activities and it can be switched between them during runtime of the application. An activity is implemented as a subclass of Activity. For example, you must have seen the Tab layout in Contact in your phone while you click on each tab each activity is being loaded.
  • Services - perform background tasks without providing an UI. They can notify the user via the notification framework in Android. A service is implemented as a subclass of Service. For example, a service might play music in the background while the user is in a different application.
  • Content Provider - provides data to applications, via a content provider your application can share data with other applications. Android contains a SQLite Database which can serve as data provider. Through the content provider other applications can query or even modify the data (if the content provider allows it).It is implemented as a subclass of ContentProvider. For example, the Android system provide a content provider that manages the user’s contact information. As such, any application with the proper permissions can query part of the content provider to read and write information about a particular person.
  • Broadcast Receiver - receives system messages and implicit intents, can be used to react to changed conditions in the system. An application can register as a Broadcast Receiver for certain events and can be started if such an event occurs.
Other Android components are Live Folders and Android Live Wallpapers. Live Folders display data on the home screen without launching the corresponding application. Some other components which we come across while programming are,
  • Views - the User interface of Activities is built with widget classes which inherent from android.view.View. The layout of the views is managed by android.view.ViewGroups. Views often have attributes which can be used to change their appearance and behavior.
  • Intents - are asynchronous messages which allow the application to request functionality from other services or activities. An application can call directly a service or activity (explicit intent) or ask the Android system for registered services and applications for intent (implicit intents). For example the application could ask via intent for a contact application. Applications register themselves to intent via an IntentFilter. Intents are a powerful concept as they allow the creation of loosely coupled applications.
  • Widgets - interactive components primary used on the Android home screen to display certain data and to allow the user to have quick access the information.
There are separate methods for activating each type of components;
·         You can start an activity (or give it something new to do) by passing an Intent to startActivity() or startActivityForResult() (when you want the activity to return a result).
·         You can start a service (or give new instructions to an ongoing service) by passing an Intent to startService() or you can bind to the service by passing an Intent to bindService().
·         You can initiate a broadcast by passing an Intent to methods like sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().
·         You can perform a query to a content provider by calling query() on a ContentResolver.

No comments:

Post a Comment