0% found this document useful (0 votes)
0 views

Chapter Two

Chapter Two covers key components of Android development including Intents, Notifications, Localization, and Menus. It explains the types of Intents (explicit and implicit), how to create notifications and toast messages, and the implementation of context and options menus. Additionally, it discusses the use of Alert Dialogs and custom dialog activities for user interactions.

Uploaded by

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

Chapter Two

Chapter Two covers key components of Android development including Intents, Notifications, Localization, and Menus. It explains the types of Intents (explicit and implicit), how to create notifications and toast messages, and the implementation of context and options menus. Additionally, it discusses the use of Alert Dialogs and custom dialog activities for user interactions.

Uploaded by

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

Chapter Two

Notification, Menus, and Dialogs


Content

 Intents with Parameters


 Notifications (Status Bar & Toast)
 Localization
 Context/Option Menu
Intents with Parameters

• An Intent in Android is a messaging object


used to request an action from another app
component.
• It allows communication between different
components such as activities, services, and
broadcast receivers.
Types of Intents

• Explicit Intent: Used to start a specific


component (e.g., start a new activity within
the same application).
• Implicit Intent: Used when the component is
not explicitly defined (e.g., sharing data with
another app).
Cont’d…
• Passing Parameters with Intents
• To pass data between activities, we use
Intent.putExtra() method:

To retrieve the data in the new activity:


Notification with Status Bar and Toast

Notification
•A Notification is a message displayed outside
the application's UI to provide updates or
reminders to the user.
Creating a Notification
Toast Notification:

– Short-lived messages that appear at


the bottom of the screen.
– Example:
Localization and Usage

•Adapting an app to different languages and regions.


•Key Components:

•Implementation:
• Usage:

Context/Option Menu
• Context Menu:
– Appears when the user performs a long press on
an item.
– Example:
Context Menu

• It appears when the user performs a long-


press (press and hold) on a UI element.
• It is typically used for contextual actions, such
as editing or deleting an item.
Options Menu

• It is a primary menu in Android that appears


in the app bar (toolbar).
• It provides quick access to frequently used
actions such as settings, search, logout, or
help.
Steps to Implement an Options Menu
1. Create the Menu XML File
The menu items are defined in an XML file inside the
res/menu/ directory.
📁 Path: res/menu/menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_settings" android:title="Settings"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction="never" /> <item
android:id="@+id/action_about" android:title="About"
android:showAsAction="never" />
</menu>
Alert Dialog

• It is used to display an alert message with


optional actions.
• It is a type of activity in Android that behaves
like a dialog rather than a full-screen window.
• It is useful for displaying temporary
information, getting user input, or confirming
actions without disrupting the user’s
workflow.
Key Features:
•Appears as a floating window.
•Does not occupy the entire screen.
•Can be themed to look like a dialog.
Dialog as Activity

• Instead of using AlertDialog, you can create a


custom dialog using an Activity with a dialog
theme.
• Steps to Create a Dialog as an Activity
1. Create a new Activity with a Dialog theme in
AndroidManifest.xml:
2Create the Dialog Activity Layout
(res/layout/dialog_activity.xml)
Cont’d….
3. Start the Dialog Activity

4. Implement UI and logic in DialogActivity.java


• 2. Implement UI and logic in DialogActivity.java

You might also like