Wednesday, 28 September 2016

Building Blocks of Android

Application components are the building blocks of android application.It is a component of code that can be defined as four different components that can used within Android application.

There four main components are given below.

1) Activities
2) Services
3) Content Providers
4) Broadcast Receivers

Activities :-

      It represents a single screen with a user interface and it has most important part of building blocks.For example an email app might have one activity that shows a list of new emails,one activity to compose an email and another one activity for reading emails.

Ex- public class MainActivity extends Acticvity{

Services :-

Service is a component that run background to perform longtime run.It does not provide UI(user interface).It has two types of services one is local and second is remote.

Ex- public class MyService extends Service {

Content Providers :- 

 Content providers sharing between two set of app data.

Ex- public class MyContentProvider extends ContentProvider {
       public void onCreate() {

Broadcast Receivers :- 

 It is a component that responds to system wide broadcast announcements.And many broadcasts are orginate from system.
    For example applications can also initiatebroadcasts to let other applications know that some data has been downloaded to device and is available for them to use so broadcast receiver will intercept tthis communication and will initiate appropriate action.

Ex-   public class MyBroadcastReciever extends BroadcastReciever {
        public void onReceive(context,intent) {

No comments:

Post a Comment