5

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.

Ran
  • 4,117
  • 4
  • 44
  • 70

1 Answers1

6

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

John
  • 460
  • 1
  • 5
  • 18
Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • Ok, thanks. I just don't like adding unnecessary permisssions. :) – Ran Feb 09 '13 at 17:10
  • 1
    @Ahmad, you're welcome :) I ran across that info in the docs today and figured I would add it to the answer. – John May 12 '15 at 21:52