开发者

Binding to a local Service from a BroadcastReceiver

My application has the following components:

2 Activities

A Service and a

BroadcastReceiver

Whenever the us开发者_如何转开发er updates the system time, my broadcast receiver receives the Intent.ACTION_TIME_CHANGED. Now when this happens I want to reschedule a Handler in my Service. How do I bind to a Service within my BroadcastReceiver?


Your service can catch the intent directly without any BroadcastReceiver help.

Can be done by adding intent-filter to your service. There are two ways to do that:

  1. by static definition at AndroidManifest.xml file ( link text ) )
  2. you can register receiver in the code context.registerReceiver(your_receiver, new IntentFilter(Intent.ACTION_TIME_CHANGED));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜