ANDROID PROGRAMMING

components of Android Application

 what are the components of Android Application?

There are following four main components that can be used within an Android application:


Activities:
An activity represents a single screen of an android application. They dictate the UI and handle the user interaction to the smartphone screen. An application may contain one or more activities. Like a contact book in your phone where you see 1 activity for adding new contacts, 1 for showing and for deleting contacts means that there exists more than one activity in an app.

An activity is implemented as a subclass of Activity class as follows:-

public class Main Activity extends Activity {

}


Services:
A service is a component that runs in the background to perform long running tasks. We can say that they handle background processing associated with an application. Like downloading, playing music in the background etc.

A service is implemented as a subclass of Service class as follows:-

public class MyService extends Service {

}
Broadcast Receivers:

Broadcast Receivers respond to messages that are broadcasted by other applications or from the system. we can say the Broadcaster Receivers can handle communication between Android OS and the applications.
A broadcast receiver is implemented as a subclass of Broadcast Receiver class and each message is broadcasted as an Intent object like as :-
public class Receiver extends Broadcast Receiver {

}
Content Providers:

 A content provider is that component which supplies data from one application to another or to others on request. These requests are handled by methods of Content Resolver class. In short content providers handle data and database management issues, in which data is stored in a file system, or in a database etc.

A content provider is implemented as a subclass of Content Provider class and must implement a standard set of APIs that enable other applications to perform transactions as:-.

public class MyContentProvider extends ContentProvider {

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button