From the course: Android App Development: Working with Widgets

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Exploration of AppWidgetProvider classes

Exploration of AppWidgetProvider classes - Android Tutorial

From the course: Android App Development: Working with Widgets

Start my 1-month free trial

Exploration of AppWidgetProvider classes

- [Instructor] Now, let's move on to the provider classes and explore what they are, and how we can use them. The first one is onUpdate; this class is called to update the widget based on the milliseconds you set in the info file we explored in the last video. This allows you to update the widget, and this class is called whenever the user adds the widget. The next method is called onEnabled, which is called the first time the widget is created. So whatever code you put in there will be executed when the user place a new widget on the screen. Then we have a method called onDisabled, which is when a user removes a widget from its screen. For example, if you create a mini database or some (mumbles) data, upon creation, this is when you'd remove these items and use this method to do so. And finally you have onAppWidgetOptionsChanged, this is a method that is called whenever the widget is resized or when placed on the screen. So if we take a look into our current code, we have a function…

Contents