SlideShare ist ein Scribd-Unternehmen logo
1 von 16
ANDROID
WIDGET
Topics
 What is an App Widget?
App Widget framework
Steps for creating an App Widget
Creating App Widget
configuration Activity
What is App Widget?
Widgets are an essential aspect of home screen
customization. You can imagine them as "at-a-glance"
views of an app's most important data and
functionality that is accessible right from the user's
home screen.
Usage Examples of App Widgets
• People can drop widgets onto their home
screen and interact.
• Widgets can provide a quick glimpse into fully
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.
AppWidget Framework
• 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.
AppWidget Framework
• 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.
AppWidget Framework(cont..)
• View layout
> Defines the initial layout for the App
Widget, defined in XML.
• Additionally, you can implement an App Widget
configuration Activity.
Steps for Building an App Widget
Declare an AppWidgetProvider in the Manifest
file
Create the AppWidgetProviderInfo Metadata
XML file
Create the App Widget Layout XML file
Write the AppWidgetProvider Class
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
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 AppWidget, and
(optionally) a configuration Activity to launch at create time.
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
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)
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
colour, 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_CONFI
GURE" />
</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.ExampleAppWidgetC
onfigure"
... >
</appwidget-provider>
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

android activity
android activityandroid activity
android activity
Deepa Rani
 
android architecture
android architectureandroid architecture
android architecture
Aashita Gupta
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
Krazy Koder
 

Was ist angesagt? (20)

ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
android activity
android activityandroid activity
android activity
 
android architecture
android architectureandroid architecture
android architecture
 
Webservices
WebservicesWebservices
Webservices
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Eclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATIONEclipse introduction IDE PRESENTATION
Eclipse introduction IDE PRESENTATION
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Introduction to flutter
Introduction to flutter Introduction to flutter
Introduction to flutter
 
Java Swing
Java SwingJava Swing
Java Swing
 
Tracing in ASp.Net
Tracing in ASp.NetTracing in ASp.Net
Tracing in ASp.Net
 
Java swing
Java swingJava swing
Java swing
 
Android App Development - 05 Action bar
Android App Development - 05 Action barAndroid App Development - 05 Action bar
Android App Development - 05 Action bar
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
Android UI
Android UIAndroid UI
Android UI
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Web services
Web servicesWeb services
Web services
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
 
Applets in java
Applets in javaApplets in java
Applets in java
 

Andere mochten auch

50-Behavior-Based-Interview-Questions
50-Behavior-Based-Interview-Questions50-Behavior-Based-Interview-Questions
50-Behavior-Based-Interview-Questions
Anirud Raghava
 
Mike Meo, Harvard GSD Core Portfolio
Mike Meo, Harvard GSD Core PortfolioMike Meo, Harvard GSD Core Portfolio
Mike Meo, Harvard GSD Core Portfolio
Michael Meo
 
OPERATE ROUGH TERAIN EQUIPMENT
OPERATE ROUGH TERAIN EQUIPMENTOPERATE ROUGH TERAIN EQUIPMENT
OPERATE ROUGH TERAIN EQUIPMENT
Lindsay Fritz
 

Andere mochten auch (18)

Fernando cembranos
Fernando cembranosFernando cembranos
Fernando cembranos
 
Levantam10
Levantam10Levantam10
Levantam10
 
test32renamed
test32renamedtest32renamed
test32renamed
 
k12020 control theory ppt
k12020 control theory pptk12020 control theory ppt
k12020 control theory ppt
 
Dane estetik laser
Dane estetik laserDane estetik laser
Dane estetik laser
 
50-Behavior-Based-Interview-Questions
50-Behavior-Based-Interview-Questions50-Behavior-Based-Interview-Questions
50-Behavior-Based-Interview-Questions
 
Jeff Moriarty, Johnston Press
Jeff Moriarty, Johnston PressJeff Moriarty, Johnston Press
Jeff Moriarty, Johnston Press
 
Mike Meo, Harvard GSD Core Portfolio
Mike Meo, Harvard GSD Core PortfolioMike Meo, Harvard GSD Core Portfolio
Mike Meo, Harvard GSD Core Portfolio
 
Lakhan singh
Lakhan singhLakhan singh
Lakhan singh
 
OPERATE ROUGH TERAIN EQUIPMENT
OPERATE ROUGH TERAIN EQUIPMENTOPERATE ROUGH TERAIN EQUIPMENT
OPERATE ROUGH TERAIN EQUIPMENT
 
Новые направления развития на рынке металлосервисных услуг. Опыт СПК
Новые направления развития на рынке металлосервисных услуг. Опыт СПКНовые направления развития на рынке металлосервисных услуг. Опыт СПК
Новые направления развития на рынке металлосервисных услуг. Опыт СПК
 
Microcontrollori
MicrocontrolloriMicrocontrollori
Microcontrollori
 
Equazione della circonferenza
Equazione della circonferenzaEquazione della circonferenza
Equazione della circonferenza
 
Trabajo3 sem4 gogoc
Trabajo3 sem4 gogocTrabajo3 sem4 gogoc
Trabajo3 sem4 gogoc
 
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
 
Business environment
Business environmentBusiness environment
Business environment
 
Abdomen agudo
Abdomen agudoAbdomen agudo
Abdomen agudo
 
Medio natural
Medio naturalMedio natural
Medio natural
 

Ähnlich wie Android Widget

Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
Krazy Koder
 
FlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.pptFlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.ppt
KevinNemo
 

Ähnlich wie Android Widget (20)

Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 
FlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.pptFlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.ppt
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
App widget
App widgetApp widget
App widget
 
Beginning android
Beginning android Beginning android
Beginning android
 
Dicoding Developer Coaching #21: Android | Cara Membuat Widget di Aplikasi An...
Dicoding Developer Coaching #21: Android | Cara Membuat Widget di Aplikasi An...Dicoding Developer Coaching #21: Android | Cara Membuat Widget di Aplikasi An...
Dicoding Developer Coaching #21: Android | Cara Membuat Widget di Aplikasi An...
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Android Wear, a developer's perspective
Android Wear, a developer's perspectiveAndroid Wear, a developer's perspective
Android Wear, a developer's perspective
 
Compose camp 4.pptx
Compose camp 4.pptxCompose camp 4.pptx
Compose camp 4.pptx
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Android by Swecha
Android by SwechaAndroid by Swecha
Android by Swecha
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Workshop Android for Java Developers
Workshop Android for Java DevelopersWorkshop Android for Java Developers
Workshop Android for Java Developers
 
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
 
Web application development process
Web application development processWeb application development process
Web application development process
 
Android components
Android componentsAndroid components
Android components
 
Ui 5
Ui   5Ui   5
Ui 5
 
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
 
Mobile Application Development class 003
Mobile Application Development class 003Mobile Application Development class 003
Mobile Application Development class 003
 

Kürzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Kürzlich hochgeladen (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Android Widget

  • 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? Widgets are an essential aspect of home screen customization. You can imagine them as "at-a-glance" views of an app's most important data and functionality that is accessible right from the user's home screen.
  • 4. Usage Examples of App Widgets • People can drop widgets onto their home screen and interact. • Widgets can provide a quick glimpse into fully 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.
  • 5. AppWidget Framework • 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.
  • 6. AppWidget Framework • 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.
  • 7. AppWidget Framework(cont..) • View layout > Defines the initial layout for the App Widget, defined in XML. • Additionally, you can implement an App Widget configuration Activity.
  • 8. Steps for Building an App Widget Declare an AppWidgetProvider in the Manifest file Create the AppWidgetProviderInfo Metadata XML file Create the App Widget Layout XML file Write the AppWidgetProvider Class
  • 9. 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
  • 10. 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 AppWidget, and (optionally) a configuration Activity to launch at create time.
  • 11. 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
  • 12. 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)
  • 13. 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 colour, size, update period or other functionality settings.
  • 14. 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_CONFI GURE" /> </intent-filter> </activity>
  • 15. 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.ExampleAppWidgetC onfigure" ... > </appwidget-provider>