SlideShare a Scribd company logo
App Widgets
Topics
• What is an App Widget?
• App Widget framework
• Steps for creating an App Widget
• Creating App Widget configuration Activity
What is App Widget?
What is App Widget?
• App Widgets are
miniature application
views that can be
embedded in other
applications (such as
the Home screen) and
receive periodic
updates.
Widdget
Usage Examples of App Widgets
• People can drop widgets onto their home
screen and interact with
• Widgets can provide a quick glimpse into full-
featured apps, such as showing upcoming
calendar events, or viewing details about a
song playing in the background.
• Users can also interact with your app through
the widget, for example pausing or switching
music tracks.
Music App Widget
AppWidget Framework
Things that make up an App Widget
• AppWidgetProviderInfo object
> Describes the metadata for an App Widget, such as
the App Widget's layout, update frequency, and the
AppWidgetProvider class.
> This should be defined in XML.
• AppWidgetProvider class
> Defines the basic methods that allow you to
programmatically interface with the App Widget,
based on broadcast events. (AppWidgetProvider
class is a child class of BroadcastReceiver class.)
> Through it, you will receive broadcasts when the App
Widget is updated, enabled, disabled and deleted.
Things that make up an App Widget
• View layout
> Defines the initial layout for the App Widget, defined
in XML.
• Additionally, you can implement an App Widget
configuration Activity.
> This is an optional Activity that launches when the
user adds your App Widget and allows him or her to
modify App Widget settings at create-time.
Steps for Building
an
App Widget
Steps for Building an App Widget
1.Declare an AppWidgetProvider in the Manifest
file
2.Create the AppWidgetProviderInfo Metadata
XML file
3.Create the App Widget Layout XML file
4.Write the AppWidgetProvider Class
1. Declare AppWidgetProvider in Manifest
• The <receiver> element requires the android:name
attribute, which specifies the AppWidgetProvider
• The <intent-filter> element must include an <action>
element with the android:name attribute. This attribute
specifies that the AppWidgetProvider accepts the
ACTION_APPWIDGET_UPDATE broadcast.
• The <meta-data> element specifies the location of the
AppWidgetProviderInfo meta-data resource file
<receiver android:name="ExampleAppWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/example_appwidget_info" />
</receiver>
2. Create AppWidgetProviderInfo Metadata
• Define the AppWidgetProviderInfo object in an XML
resource using a single <appwidget-provider> element
and save it in the project's res/xml/ folder.
> This file is referenced from the manifest file
• Defines the essential qualities of an App Widget, such
as its minimum layout dimensions, its initial layout
resource, how often to update the App Widget, and
(optionally) a configuration Activity to launch at create-
time.
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/example_appwidget"
android:configure="com.example.android.ExampleAppWidgetConfigure" >
</appwidget-provider>
3. Create App Widget Layout
• App Widget layouts are based on RemoteViews,
which do not support every kind of layout or
view widget.
• A RemoteViews object (and, consequently, an
App Widget) can support the following layouts
and Widget classes
> FrameLayout, LinearLayout, RelativeLayoyt
> AnalogClock, Button, Chronometer, ImageButton,
ImageView, ProgressBar, TextView
4. Write AppWidgetProvider Class
• The AppWidgetProvider class extends
BroadcastReceiver as a convenience class to
handle the App Widget broadcasts
• Methods to override
> onUpdate(Context, AppWidgetManager, int[]) - called
when each App Widget is added to a host (unless you
use a configuration Activity), Typically the only
method that needs to be present
> onDeleted(Context, int[])
> onEnabled(Context)
> onDisabled(Context)
> onReceive(Context, Intent)
Example AppWidgetProvider
public class ExampleAppWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
final int N = appWidgetIds.length;
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);
// Tell the AppWidgetManager to perform an update on the current App Widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}
Create App Widget Configuration
Why App Widget Configuration Activity?
• If you would like the user to configure settings
when he or she adds a new App Widget, you
can create an App Widget configuration
Activity.
• This Activity will be automatically launched by
the App Widget host and allows the user to
configure available settings for the App Widget
at create-time, such as the App Widget color,
size, update period or other functionality
settings.
Declare it in Manifest File
• The configuration Activity should be declared as a normal
Activity in the Android manifest file.
• However, it will be launched by the App Widget host with
the ACTION_APPWIDGET_CONFIGURE action, so the Activity
needs to accept this Intent
<activity android:name=".ExampleAppWidgetConfigure">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
Declare it in Metadata Config file
• Also, the Activity must be declared in the
AppWidgetProviderInfo XML file, with the android:configure
attribute
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
...
android:configure="com.example.android.ExampleAppWidgetConfigure"
... >
</appwidget-provider>
Thank you
Ad

More Related Content

What's hot (20)

Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
Vibrant Technologies & Computers
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
AqsaHayat3
 
Android UI
Android UIAndroid UI
Android UI
nationalmobileapps
 
Android Services
Android ServicesAndroid Services
Android Services
Ahsanul Karim
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
PRITI TELMORE
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
Android notification
Android notificationAndroid notification
Android notification
Krazy Koder
 
Alarms
AlarmsAlarms
Alarms
maamir farooq
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
myrajendra
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineering
kirupasuchi1996
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
Kan-Han (John) Lu
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
Adil Mehmoood
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
AqsaHayat3
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
PRITI TELMORE
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
Android notification
Android notificationAndroid notification
Android notification
Krazy Koder
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
myrajendra
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineering
kirupasuchi1996
 

Viewers also liked (11)

Android location
Android locationAndroid location
Android location
Krazy Koder
 
Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0
Gracia Marcom
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
Mohammad Shaker
 
Action Bar and Menu
Action Bar and MenuAction Bar and Menu
Action Bar and Menu
Katsumi Onishi
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
Krazy Koder
 
Android ui dialog
Android ui dialogAndroid ui dialog
Android ui dialog
Krazy Koder
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in android
Durai S
 
Android ui menu
Android ui menuAndroid ui menu
Android ui menu
Krazy Koder
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
Jussi Pohjolainen
 
Android adapters
Android adaptersAndroid adapters
Android adapters
baabtra.com - No. 1 supplier of quality freshers
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
Ad

Similar to Android appwidget (20)

Android Widget
Android WidgetAndroid Widget
Android Widget
ELLURU Kalyan
 
Android App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgetsAndroid App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgets
Diego Grancini
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
Richard Hyndman
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
Angelo Rüggeberg
 
Android Homescreen Widgets Demystified
Android Homescreen Widgets DemystifiedAndroid Homescreen Widgets Demystified
Android Homescreen Widgets Demystified
Pearl Chen
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
umesh patil
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
Perfect APK
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Gordon Bockus
 
Learning Android Part 2/6
Learning Android Part 2/6Learning Android Part 2/6
Learning Android Part 2/6
Girish Bellalcheru
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
Junda Ong
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptx
KNANTHINIMCA
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
Fun2Do Labs
 
Android programming basics
Android programming basicsAndroid programming basics
Android programming basics
Egerton University
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
Vitali Pekelis
 
Using And Extending The DotNetNuke Widget Framework
Using And Extending The DotNetNuke Widget FrameworkUsing And Extending The DotNetNuke Widget Framework
Using And Extending The DotNetNuke Widget Framework
Nik Kalyani
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
Vijay Rastogi
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
maamir farooq
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorial
Anh Quân
 
Android App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgetsAndroid App Development - 13 Broadcast receivers and app widgets
Android App Development - 13 Broadcast receivers and app widgets
Diego Grancini
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
Richard Hyndman
 
Implementing cast in android
Implementing cast in androidImplementing cast in android
Implementing cast in android
Angelo Rüggeberg
 
Android Homescreen Widgets Demystified
Android Homescreen Widgets DemystifiedAndroid Homescreen Widgets Demystified
Android Homescreen Widgets Demystified
Pearl Chen
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
umesh patil
 
BroadcastReceivers in Android
BroadcastReceivers in AndroidBroadcastReceivers in Android
BroadcastReceivers in Android
Perfect APK
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Gordon Bockus
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
Junda Ong
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptx
KNANTHINIMCA
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
Fun2Do Labs
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
Vitali Pekelis
 
Using And Extending The DotNetNuke Widget Framework
Using And Extending The DotNetNuke Widget FrameworkUsing And Extending The DotNetNuke Widget Framework
Using And Extending The DotNetNuke Widget Framework
Nik Kalyani
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
Oro Inc.
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
Vijay Rastogi
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
maamir farooq
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorial
Anh Quân
 
Ad

More from Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
Krazy Koder
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
Krazy Koder
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
Krazy Koder
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
Krazy Koder
 
2310 b 17
2310 b 172310 b 17
2310 b 17
Krazy Koder
 
2310 b 16
2310 b 162310 b 16
2310 b 16
Krazy Koder
 
2310 b 16
2310 b 162310 b 16
2310 b 16
Krazy Koder
 
2310 b 15
2310 b 152310 b 15
2310 b 15
Krazy Koder
 
2310 b 15
2310 b 152310 b 15
2310 b 15
Krazy Koder
 
2310 b 14
2310 b 142310 b 14
2310 b 14
Krazy Koder
 
2310 b 13
2310 b 132310 b 13
2310 b 13
Krazy Koder
 
2310 b 12
2310 b 122310 b 12
2310 b 12
Krazy Koder
 
2310 b 11
2310 b 112310 b 11
2310 b 11
Krazy Koder
 
2310 b 10
2310 b 102310 b 10
2310 b 10
Krazy Koder
 
2310 b 09
2310 b 092310 b 09
2310 b 09
Krazy Koder
 
2310 b 08
2310 b 082310 b 08
2310 b 08
Krazy Koder
 
2310 b 08
2310 b 082310 b 08
2310 b 08
Krazy Koder
 
2310 b 08
2310 b 082310 b 08
2310 b 08
Krazy Koder
 
2310 b 07
2310 b 072310 b 07
2310 b 07
Krazy Koder
 
2310 b 06
2310 b 062310 b 06
2310 b 06
Krazy Koder
 

Recently uploaded (20)

The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 

Android appwidget

  • 2. Topics • What is an App Widget? • App Widget framework • Steps for creating an App Widget • Creating App Widget configuration Activity
  • 3. What is App Widget?
  • 4. What is App Widget? • App Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic updates. Widdget
  • 5. Usage Examples of App Widgets • People can drop widgets onto their home screen and interact with • Widgets can provide a quick glimpse into full- featured apps, such as showing upcoming calendar events, or viewing details about a song playing in the background. • Users can also interact with your app through the widget, for example pausing or switching music tracks. Music App Widget
  • 7. Things that make up an App Widget • AppWidgetProviderInfo object > Describes the metadata for an App Widget, such as the App Widget's layout, update frequency, and the AppWidgetProvider class. > This should be defined in XML. • AppWidgetProvider class > Defines the basic methods that allow you to programmatically interface with the App Widget, based on broadcast events. (AppWidgetProvider class is a child class of BroadcastReceiver class.) > Through it, you will receive broadcasts when the App Widget is updated, enabled, disabled and deleted.
  • 8. Things that make up an App Widget • View layout > Defines the initial layout for the App Widget, defined in XML. • Additionally, you can implement an App Widget configuration Activity. > This is an optional Activity that launches when the user adds your App Widget and allows him or her to modify App Widget settings at create-time.
  • 10. Steps for Building an App Widget 1.Declare an AppWidgetProvider in the Manifest file 2.Create the AppWidgetProviderInfo Metadata XML file 3.Create the App Widget Layout XML file 4.Write the AppWidgetProvider Class
  • 11. 1. Declare AppWidgetProvider in Manifest • The <receiver> element requires the android:name attribute, which specifies the AppWidgetProvider • The <intent-filter> element must include an <action> element with the android:name attribute. This attribute specifies that the AppWidgetProvider accepts the ACTION_APPWIDGET_UPDATE broadcast. • The <meta-data> element specifies the location of the AppWidgetProviderInfo meta-data resource file <receiver android:name="ExampleAppWidgetProvider" > <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/example_appwidget_info" /> </receiver>
  • 12. 2. Create AppWidgetProviderInfo Metadata • Define the AppWidgetProviderInfo object in an XML resource using a single <appwidget-provider> element and save it in the project's res/xml/ folder. > This file is referenced from the manifest file • Defines the essential qualities of an App Widget, such as its minimum layout dimensions, its initial layout resource, how often to update the App Widget, and (optionally) a configuration Activity to launch at create- time. <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="294dp" android:minHeight="72dp" android:updatePeriodMillis="86400000" android:initialLayout="@layout/example_appwidget" android:configure="com.example.android.ExampleAppWidgetConfigure" > </appwidget-provider>
  • 13. 3. Create App Widget Layout • App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget. • A RemoteViews object (and, consequently, an App Widget) can support the following layouts and Widget classes > FrameLayout, LinearLayout, RelativeLayoyt > AnalogClock, Button, Chronometer, ImageButton, ImageView, ProgressBar, TextView
  • 14. 4. Write AppWidgetProvider Class • The AppWidgetProvider class extends BroadcastReceiver as a convenience class to handle the App Widget broadcasts • Methods to override > onUpdate(Context, AppWidgetManager, int[]) - called when each App Widget is added to a host (unless you use a configuration Activity), Typically the only method that needs to be present > onDeleted(Context, int[]) > onEnabled(Context) > onDisabled(Context) > onReceive(Context, Intent)
  • 15. Example AppWidgetProvider public class ExampleAppWidgetProvider extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this provider for (int i=0; i<N; i++) { int appWidgetId = appWidgetIds[i]; // Create an Intent to launch ExampleActivity Intent intent = new Intent(context, ExampleActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); // Get the layout for the App Widget and attach an on-click listener to the button RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout); views.setOnClickPendingIntent(R.id.button, pendingIntent); // Tell the AppWidgetManager to perform an update on the current App Widget appWidgetManager.updateAppWidget(appWidgetId, views); } } }
  • 16. Create App Widget Configuration
  • 17. Why App Widget Configuration Activity? • If you would like the user to configure settings when he or she adds a new App Widget, you can create an App Widget configuration Activity. • This Activity will be automatically launched by the App Widget host and allows the user to configure available settings for the App Widget at create-time, such as the App Widget color, size, update period or other functionality settings.
  • 18. Declare it in Manifest File • The configuration Activity should be declared as a normal Activity in the Android manifest file. • However, it will be launched by the App Widget host with the ACTION_APPWIDGET_CONFIGURE action, so the Activity needs to accept this Intent <activity android:name=".ExampleAppWidgetConfigure"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> </intent-filter> </activity>
  • 19. Declare it in Metadata Config file • Also, the Activity must be declared in the AppWidgetProviderInfo XML file, with the android:configure attribute <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" ... android:configure="com.example.android.ExampleAppWidgetConfigure" ... > </appwidget-provider>