Tuesday 22 October 2013

The Basics of Android Development - Application Components

                                                         Application  Components


"A program is written well when you can understand what  the program does just by looking at the code -  Anonymous".

An Android application is made up of Building blocks called Application components.There are 4 application components in Android, they are:

1) Activity.
2) BroadcastReceiver.
3) Services.
4) Content Providers.

Activity: Each Screen in an Android App is an Activity.  An activity is a window on which you can
place UI elements like TextFields, Images, Buttons, Lists etc.

BroadcastReceiver: As the Name Suggests A broadcast receiver is meant to receive broadcasts. Broadcasts are messages/events that are broadcaste either by the system or by other applications or by components within your own application.

Use cases for BroadcastReceiver:
       Passing messages within your Application; you can send a message from one module and receive it in another module. very handy for event handling in apps.

System regularly send broadcasts w hen Battery is down, Network goes down or network comes up, Aeroplane mode is switched on or switched off.
You can receive these system broadcasts  if you want to handle a particular scenario(like Network Down) within your app.

Services: Service is used to perform long running background tasks for example something like a file download from a server. Please note that the Service is not a 'Thread' and is not meant to do tasks in an asynchronous manner.
Another use of Service is that it can provide for IPC(Inter Process communication/Client-Server) facility for android apps.

We shall revisit the important and meaty concept of Service in a separate dedicated chapter.


ContentProviders: As the Name suggests the use of content providers is when you want your application to provide access of its data to other apps.
Basic Applications like Contacts, Calendar, Browser etc provide content via Content-Providers, now you know how applications like WhatsApp or WeChat get access to your phone contacts.

We end this blog here for today, Stay tuned for more tutorials from this Blog folks, much more to share and much more to learn...

Quote Corner:

“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds 


No comments:

Post a Comment