Dianne,

I have used both AlarmManager.ELAPSED_REALTIME_WAKEUP and
AlarmManager.RTC_WAKEUP.

I am currently setting a repeating alarm "attached" to a pending
intent in the GUI portion of the application. The pending intent
starts the service.

objPendingIntent = PendingIntent.getService(bServiceGUI.this, 0, new
Intent(bServiceGUI.this, bService.class), 0);

// Schedule the alarm!
long firstTime = SystemClock.elapsedRealtime();
AlarmManager objAlarmManager = (AlarmManager)getSystemService
(ALARM_SERVICE);
objAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
firstTime, 5*60*1000, objPendingIntent);


in the service

@Override
public void onCreate()
{
        super.onCreate();

        Thread objThread = new Thread(null, doTasks, "bService");
        objThread.start();
}


private Runnable doTasks = new Runnable()
{
        public void run()
        {
                PowerManager objPowerManager = null;
                PowerManager.WakeLock objWakeLock = null;

                try
                {

                        objPowerManager = (PowerManager) getSystemService
(Context.POWER_SERVICE);
                        //objWakeLock = objPowerManager.newWakeLock
(PowerManager.FULL_WAKE_LOCK, "bService_Class");
                        objWakeLock = objPowerManager.newWakeLock
(PowerManager.PARTIAL_WAKE_LOCK, "bService_Class");
                        objWakeLock.acquire();

                        //Your processing tasks here.
                }
                catch (Exception e)
                {
                }
                finally
                {
                        try
                        {
                                objWakeLock.release();
                        }
                        catch (Exception e1)
                        {
                        }
                }

                bService.this.stopSelf();
        }
};

On Mar 27, 1:34 pm, Dianne Hackborn <[email protected]> wrote:
> And are you using a partial wake lock?  Note that if you absolutely need to
> run even when the device is asleep, this can be a little tricky -- you need
> to deliver the alarm to a broadcast receive (the alarm manager holds a wake
> lock during this time), acquire a partial wake lock there and start your
> service and don't release the wake lock until the service is done with its
> work.
>
> This is unfortunately tricky to do right now; in the future we would really
> like to make wakelock management easier for these situations.
>
> On Fri, Mar 27, 2009 at 10:10 AM, Mariano Kamp <[email protected]>wrote:
>
>
>
>
>
> > Hard to judge without any code.
> > Do you use AlarmManager.RTC_WAKEUP?
>
> > On Fri, Mar 27, 2009 at 5:45 PM, Mark Murphy <[email protected]>wrote:
>
> >> clarkbriancarl wrote:
> >> > THanks for the reply. I use your book as a reference from time to
> >> > time. I would recommend it to anyone reading this.
>
> >> Thanks!
>
> >> > Before I open an issue, I would like to hear from other developers to
> >> > see if their experiences have been similar, and if not, do some code
> >> > comparison to see what they are doing different. I just want to make
> >> > sure this is an issue and not a mistake on my part.
>
> >> > I am willing to post some code if it is needed.
>
> >> I'm sure there are some folk who could eyeball some sample code and
> >> point out possible problems but may not have source they are in position
> >> to upload. That's one of the many advantages of having sample projects
> >> that reproduce possible bugs.
>
> >> Your issue illustrates, though, that I need to beef up my AlarmService
> >> section in the Advanced Android book, so I'll try to spend some time
> >> reproducing your scenario and seeing if I get similar results. To invert
> >> the Stones, "Ti-i-i-ime is not on my side (no it ain't)", but I'll
> >> hopefully be able to squeeze this in this weekend.
>
> >> --
> >> Mark Murphy (a Commons Guy)
> >>http://commonsware.com
> >> Android App Developer Training:http://commonsware.com/training.html
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support.  All such questions should be posted on public
> forums, where I and others can see and answer them.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to