Ragunath Jawahar
Ragunath Jawahar

Reputation: 19723

Binding to a local Service from a BroadcastReceiver

My application has the following components:
2 Activities
A Service and a
BroadcastReceiver

Whenever the user 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?

Upvotes: 1

Views: 3751

Answers (1)

Damian Kołakowski
Damian Kołakowski

Reputation: 2741

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));

Upvotes: 3

Related Questions