Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 17. AppWidgets > Updating the AppWidget

17.8. Updating the AppWidget

Our AppWidget instances on the home screen are only useful if they’re actually keeping data up-to-date. One means for performing this update is to solely rely on the AppWidgetProvider’s onUpdate() method. The onUpdate() method is invoked periodically according to the schedule specified in the metadata file.

One reason for updating the widget outside of the AppWidgetProvider is to provide more granularity than afforded by the built-in scheduling mechanism. For example, you may wish to update the data more frequently than once per hour depending on the conditions. Imagine an AppWidget that tracks stock prices. It makes little sense to have the widget update when the market is closed, and it wouldn’t be unreasonable to update once every 15 minutes during market hours.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial