0% found this document useful (0 votes)
7 views5 pages

UI Componenets and Layout (8 Marks)

The document outlines key concepts of Android development, including UI components, layouts, and control flow. It details the four main Android components: Activities, Services, Broadcast Receivers, and Content Providers, along with their functions and implementations. Additionally, it mentions other components like Fragments, Views, Intents, and the Android Virtual Device (AVD) for testing applications.

Uploaded by

sandeshlahane901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

UI Componenets and Layout (8 Marks)

The document outlines key concepts of Android development, including UI components, layouts, and control flow. It details the four main Android components: Activities, Services, Broadcast Receivers, and Content Providers, along with their functions and implementations. Additionally, it mentions other components like Fragments, Views, Intents, and the Android Virtual Device (AVD) for testing applications.

Uploaded by

sandeshlahane901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

UI Components and Layouts

UI (User Interface) components are the elements used to design the


visual structure of an application.
A Layout is a container that defines the structure of UI elements (widgets)
in an app. It determines how views (buttons, text, images, etc.) are
arranged on the screen.

Control Flow
Control means managing how an app behaves.
1
Flow means the direction of something from one point to another.
Control flow refers to the order in which the instructions or code are
executed based on conditions, events, and user interactions.

Control Flow:
1. Open the Android Studio.
2. Select File -> New -> New Project.
3. Select Empty Activity and click ‘Next’.
4. Give the Project Name and click ‘Finish’.

Android Components / Android Core Building Blocks


Android components are the building blocks of an Android application.

 There are four main components that can be used within an


Android application:
2
1. Activities
2. Services
3. Broadcast Receivers
4. Content Providers

1. Activity:
- An activity is a class that represents a single screen. It is like a Frame
in AWT.
- They dictate the UI and handle the user interaction to the smart phone
screen.
- Example: Login screen, Home screen.
- An activity is implemented as a subclass of Activity class:
public class MainActivity extends Activity {

2. Services:
- A service is a component that runs in the background without UI to
perform long-running operations.
- They handle background processing associated with an application.
- For example: A service might play music in the background while the
user is in a different application, or it might fetch data over the
network without blocking user interaction with an activity.
- A service is implemented as a subclass of Service class:
public class MyService extends Service {

3. Broadcast Receivers:
- Broadcast receivers is a simply respond to broadcast messages from
other applications or from the system.
- They handle communication between Android OS and application.
- Example: Battery low alert, SMS received notification.
- A Broadcast Receiver is implemented as a subclass of
BroadcastReceiver class and each message as an Intent object.
public class MyReceiver extends BroadcastReceiver {
public void onReceive(content, intent) {
3
}
}

4. Content Providers:
- A content provider component supplies data from one application to
others on request / Content Providers are used to share data between
the applications.
- They handle data and database management issues.
- Example: Contacts app sharing data with WhatsApp.
- A content provider is implemented as a subclass of ContentProvider
class:
public class MyContentProvider extends ContentProvider {
public void onCreate() {

}
}

 Other Components:
1. Fragments: Fragments are like parts of activity. An activity can display one or more fragments
on the screen at the same time.
2. Views: A view is the UI element such as button, label, text field etc. Anything that you see is a
view.
3. Layouts
4. Intents:
Intent is used to invoke components. It is mainly used to:

o Start the service

4
o Launch an activity
o Display a web page
o Display a list of contacts
o Broadcast a message
o Dial a phone call etc.
For example, you may write the following code to view the webpage.

1. Intent intent=new Intent(Intent.ACTION_VIEW);


2. intent.setData(Uri.parse("http://www.javatpoint.com"));
3. startActivity(intent);

5. Resources
6. Manifest
It contains informations about activities, content providers, permissions etc. It is like the web.xml file in
Java EE.

Android Virtual Device (AVD)


It is used to test the android application without the need for mobile or tablet etc. It can be created in
different configurations to emulate different types of real devices.

Android Application Structure

You might also like