w.donahue
w.donahue

Reputation: 10906

Android Broadcast Receiver in Widget

Is it possible to register for a broadcast receiver from within a widget? I have tried a few ways and the registration seems to work but the widget is never called back when the event occurs.

Upvotes: 0

Views: 2892

Answers (3)

mbonness
mbonness

Reputation: 1692

A widget basically is a broadcast receiver, so if you want to you can statically define intent filters in your widget's AppManifest.xml and handle the broadcast intents in your widget's onReceive() method as shown here:

android update widget from broadcast receiver

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007624

Is it possible to register for a broadcast receiver from within a widget?

No, sorry. Whatever problem you are trying to solve this way can either be solved a better way or should not be solved.

Upvotes: 3

user775598
user775598

Reputation: 1323

Yes, for example: http://madandroid.blogspot.com/2011/05/registering-broadcast-receiver-from.html

Note that the BroadcastReceiver and not the widget will be called when the event occurs.

Upvotes: -2

Related Questions