On Thu, Jan 10, 2013 at 8:54 AM, Jake Colman <[email protected]> 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?

For me, 60 seconds is about the threshold where I start to wonder
whether you are doing more harm than good with AlarmManager. However,
that's just a gut feel for me -- I have not tried running any tests to
confirm whether constantly starting and stopping things will use more
power than leaving them run all the time.

> To make this a more practical question: I need to do something 30
> minutes before an astronomical event.

Hopefully the "astronomical event" doesn't involve an impact 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.

I would suggest that you give the user configuration ability here. The
power drain you are incurring may not be worth it to 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?

Triggering an event every 60 seconds indefinitely isn't great. Doing
so when it is not needed is bad. Not allowing the user to control this
behavior would also be bad. Checking location every 60 seconds may get
you slapped with a trout, particularly if the user cannot control this
behavior. And so on.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Aqui estão alguns sites onde você pode perguntar ou responder dúvidas
sobre desenvolvimento de aplicações para Android:
http://www.andglobe.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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to