Skip to Content
Android Application Development Cookbook - Second Edition
book

Android Application Development Cookbook - Second Edition

by Rick Boyer, Kyle Mew
March 2016
Intermediate to advanced
428 pages
9h 2m
English
Packt Publishing
Content preview from Android Application Development Cookbook - Second Edition

Creating a Home screen widget

Before we dig in to the code for creating an App Widget, let's cover the basics. There are three required and one optional component:

  • The AppWidgetProviderInfo file: It's an XML resource described later on
  • The AppWidgetProvider class: This is a Java class
  • The View layout file: It's a standard layout XML file, with some restrictions listed later on
  • The App Widget configuration Activity (optional): This Activity launches when placing the widget to set configuration options

The AppWidgetProvider must also be declared in the AndroidManifest file. Since the AppWidgetProvider is a helper class based on the Broadcast Receiver, it is declared in the manifest with the <receiver> element. Here is an example manifest entry:

<receiver ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android 9 Development Cookbook - Third Edition

Android 9 Development Cookbook - Third Edition

Rick Boyer

Publisher Resources

ISBN: 9781785886195Supplemental Content