tags:

views:

30

answers:

1

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?

+1  A: 

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));
Damian Kołakowski
Ok, after adding the static definition to the Manifest, how do I process the intent within the service (Incase my service is already running)? Is there any methods I should override?
Ragunath Jawahar
Probably: onCreate() { Intent intent = getIntent(); }
Damian Kołakowski
"Incase my service is already running" - ok, you can back to proxy BroadcastReceiver and call startService(), then 'onStartCommand' will be invoked at your service.
Damian Kołakowski
Great job @Damian Kołakowski. Worked for me.
Ragunath Jawahar