You should hold a wake lock only when you need to make sure the CPU will continue running. If it is during the entire time your service runs until it schedules an alarm, then that is it, but please keep this as short as possible since this is one of the things that can have a significant impact on battery life.
You need to do this on a device. You need to do this on a device, anyway, so you have some idea of how you are actually impacting the battery. On Fri, Nov 20, 2009 at 12:22 PM, Derek <[email protected]> wrote: > Thanks for the answer Dianne. > > So, is it a good idea to acquire a WakeLock at the beginning of the > service and release it at the end just after setting the PendingIntent > through AlarmManager ? > > Also, is it possible to simulate CPU to go off with Emulator ? or > forcing CPU to go off with real device connected to DDMS through USB ? > > Cheers. > > On Nov 20, 9:10 pm, Dianne Hackborn <[email protected]> wrote: > > If you don't hold a wake lock, you can't count on the CPU running. > > > > > > > > On Fri, Nov 20, 2009 at 12:01 PM, Derek <[email protected]> wrote: > > > Hi all, > > > > > Our application is running a service periodically through AlarmManager > > > and PendingIntent. Each time the service runs, it sets a new > > > PendingItent for next run. I works fine but sometimes the service > > > stops for no reason. > > > - Could it come from PowerManager? > > > - Could the CPU goes off before the end of the service? > > > - Should we setup a WakeLock within the service to prevent from CPU to > > > go off? > > > > > Thanks for any advice. > > > > > -- > > > 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]<android-developers%[email protected]> > <android-developers%[email protected]<android-developers%[email protected]> > > > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > 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, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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

