>>>>> "MM" == Mark Murphy <mmur...@commonsware.com> writes:
MM> On Thu, Jan 10, 2013 at 8:54 AM, Jake Colman <col...@ppllc.com> wrote: >> That's an interesting comment. I am using an alarm to wake myself >> every 60 seconds in order to check something. Are you saying this >> is not good practice? MM> For me, 60 seconds is about the threshold where I start to wonder MM> whether you are doing more harm than good with MM> AlarmManager. However, that's just a gut feel for me -- I have MM> not tried running any tests to confirm whether constantly MM> starting and stopping things will use more power than leaving MM> them run all the time. >> To make this a more practical question: I need to do something 30 >> minutes before an astronomical event. MM> Hopefully the "astronomical event" doesn't involve an impact MM> crater on Earth. :-) >> I use the alarm manager to send an intent to a service which >> checks for the time of that event (depends upon location and the >> device might have moved) and to see if we are within 30 minutes of >> the event. If so, it does something. MM> I would suggest that you give the user configuration ability MM> here. The power drain you are incurring may not be worth it to MM> all users of your app. >> Are you saying that the alarm manager is not the correct way to do >> this since I should not trigger alarms every 60 seconds? MM> Triggering an event every 60 seconds indefinitely isn't MM> great. Doing so when it is not needed is bad. Not allowing the MM> user to control this behavior would also be bad. Checking MM> location every 60 seconds may get you slapped with a trout, MM> particularly if the user cannot control this behavior. And so on. The location update is configurable by the user with a minimum update granularity of 1 hour. So the location can never change more often than every hour. I knew enough about battery consumption to not make the mistake of updating my location too often! It never occurred to me not to check the time every minute to see if it's now time to do my thing since I didn't think that would have a real impact on the battery. Hmmmmmm. Once I establish a location and I know the time of sunset, for example, I can set an alarm for 30 minutes prior to that time and be done with it. When I get a location update I can cancel that alarm and set a new one for the new time. That would certainly be easier on the system resources. How does a typical clock widget update itself to display a new time as the minutes go by? Does it do nothing unless the user turns on the screen (when the screen is off you don't need to know what time is) at which time it triggers an event and updates itself? -- Jake Colman -- Android Tinkerer -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en