I appreciate your answers very much. I am currently experimenting with the WakeLock and the AlarmManager, that were great hints ! Just a few words concerning the use case:
I am writing an educational app for the barometer (contained in the Nexus Prime). Surely it does not make sense to measure the atmospheric pressure once a second or once a minute. Probably once every 10-60 minutes is more appropriate in everyday life. For these cases, the AlarmManager migth be the right choice. But in some cases, it might be interesting to see more frequent updates. Think of balloonists, glider pilots, sky divers. To address these as well, I need to test with extreme settings like measuring once a second. For an hour or a few hours it might be ok to keep the CPU running if the user is aware of it and explicitly turned on the WakeLock-option. In all other cases I definetely agree with you and want to warn other developers, battery really drains fast :-o Thanks again ! On 14 Jan., 20:17, Dianne Hackborn <[email protected]> wrote: > And to really really re-iterate -- we are still only talking about > non-production code. > > On Sat, Jan 14, 2012 at 11:16 AM, Dianne Hackborn <[email protected]>wrote: > > > > > > > > > > > Also unless you make your service foreground, its process *will* be killed > > every now and then while it is in the background. > > > And you can use the AlarmManager to avoid holding a wake lock the entire > > time, but a rate of once a second is way to fast to be appropriate for that > > -- scheduling Alarms should not be in terms of anything quicker than once a > > minute and really more like once every 5 minutes or more. > > > On Sat, Jan 14, 2012 at 11:00 AM, Kristopher Micinski < > > [email protected]> wrote: > > >> The way you should read mark's response here is: > > >> "Don't keep the cpu running, this is a dumb idea, if you're really > >> doing this it probably indicates there is something wrong with your > >> design" > > >> If this is *strictly* for development, and you'll completely strip out > >> the code when you release your app, it would probably be fine. > > >> kris > > >> On Sat, Jan 14, 2012 at 1:05 PM, Mark Murphy <[email protected]> > >> wrote: > >> > On Sat, Jan 14, 2012 at 1:00 PM, Dirk <[email protected]> > >> wrote: > >> >> Is there a way to control the device's sleep phases programmatically, > >> >> so I can make sure the logging really takes place ? > > >> > Use a WakeLock to keep the CPU running. Your users may not like you > >> > much, though. > > >> > -- > >> > Mark Murphy (a Commons Guy) > >> >http://commonsware.com|http://github.com/commonsguy > >> >http://commonsware.com/blog|http://twitter.com/commonsguy > > >> > Android Training in NYC:http://marakana.com/training/android/ > > >> > -- > >> > 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 > > >> -- > >> 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 > > > -- > > 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. > > -- > 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

