Jaikishan Jalan wrote:
> Alright. I guess I jumped in too quickly to shot out my problem . I 
> figured out a way (of course with the help of all you beautiful people 
> :) ) to run my service in background. What I have done is I first call a 
> service from my intent receiver. This service in turns creates an 
> instance of Alarm Manager. Since Alarm Manager broadcasts an intent, I 
> have another intent receiver, which receives this intent and run a 
> service which will do run my logic. It seems to work for me but not sure 
> if this is the most efficient and recommendable way to do this.

As hackbod indicated, the next SDK may allow you to drop the second 
IntentReceiver outright, due to improvements in AlarmManager.

In the interim...you seem to have twice as many IntentReceivers and 
Services than would seem necessary.

If this were my app, I would aim for:

-- IntentReceiver (A) receives the BOOT_COMPLETED Intent and uses that 
to start the service

-- Service (B), on startup, registers an inner class IntentReceiver via 
registerReceiver() for my private Intent, then sets up AlarmManager to 
raise that Intent every N minutes, with the inner class IntentReceiver 
doing the desired work.

Then, if that worked, I'd try to get rid of (A) by registering the 
BOOT_COMPLETED intent-filter on (B), to see if I can knock this down to 
a single service class (plus an inner IntentReceiver class).

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training on the Ranch in September! http://www.bignerdranch.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to