开发者

Update Widget on System Broadcast Intent

I'm working on an Android widget that will show the current network state (i.e 1xRTT, EvDo Rev. A, WiMax, etc.). It may seem like a pointless idea, but for whatever the reason, the Evo doesn't differentiate between 1x & EvDo, it just says 3G for both, which is annoying if you're in a fringe 3G area.

Anyways, to the point: I have the widget complete and it updates with the current n开发者_运维知识库etwork just fine, but how can I make it update whenever the connection changes? I know I can use a BroadcastReceiver to catch the ConnectivityManager.CONNECTIVITY_ACTION intent the system sends on a connection change. How can I update the widget from there?

Or can I use the AppWidgetProvider to catch the intent and then update?

I know how to catch the intent, I just don't know how to update the widget once I do.


Or can I use the AppWidgetProvider to catch the intent and then update?

That should work. You will need to override onReceive(), look for CONNECTIVITY_ACTION Intents, handle those yourself, and chain to the superclass for the default behavior.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜