开发者

Android AppWidgetProvider and BroadcastReceivers

开发者 https://www.devze.com 2023-01-04 19:24 出处:网络
The online android documentation says: Everything you can do with AppWidgetProvider, you can do with a regular BroadcastReceiver.

The online android documentation says:

Everything you can do with AppWidgetProvider, you can do with a regular BroadcastReceiver.

So, what i want to do is to register via registerReceiver() another event other than ACTION_APPWIDGET_* on my Widget. For example ACTION_BATTERY_OKAY, is there any way to do this? Obviously i cant register the event from the onUpdate() code but i should 开发者_如何学编程do it using a service or something else. The problem is that im not able to find any reference to the Provider (AppWidgetManager only returns AppWidgetProviderInfo objects).

Any idea?


i think you would want to define your ACTION_BATTERY_OKAY intent filter in your AndroidManifest.xml and then override the onReceive and be sure to call super.onReceive to handle the appwidget dispatching.

0

精彩评论

暂无评论...
验证码 换一张
取 消