Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AppWidget onUpdate on boot

Does an onUpdate AppWidget called on boot?

I'm setting an alarm in the onUpdate and I wanted to know if the onUpdate will get called on boot or should I use the BOOT_COMPLETED intent.

Thanks.

like image 418
Ran Avatar asked Feb 09 '13 14:02

Ran


1 Answers

I didn't find anything in the docs regarding this so I just tested it out. I set a Toast in the onUpdate() method of my widget to see when it's triggered. After restarting the device it got triggered, so I assume that you don't need to use the BOOT_COMPLETED intent, but sometimes you can't be sure enough(there is nothing against still using it).

Edit:

onUpdate() does get called on boot and the Android docs do cover this:

onUpdate()

Called in response to the ACTION_APPWIDGET_UPDATE and ACTION_APPWIDGET_RESTORED broadcasts when this AppWidget provider is being asked to provide RemoteViews for a set of AppWidgets. Override this method to implement your own AppWidget functionality.

Source

ACTION_APPWIDGET_UPDATE

This may be sent in response to a new instance for this AppWidget provider having been instantiated, the requested update interval having lapsed, or the system booting.

Source

like image 166
Ahmad Avatar answered Sep 20 '22 05:09

Ahmad