Friday, July 15, 2011

[android-developers] Re: Weird java.util.Timer behavior in App Widget

What I want to do is simple. I want my AppWidget to have a label which
reads

"Updated: n seconds ago"
"Updated: n minutes ago"
"Updated: n hours ago"
"Updated ages ago"

The labels text will depend on how long its been since a button on the
widget was pressed. I am very conscious of battery power so I don't
want a Timer or an Alarm to fire every second which checks how long
its been.

What I want is a Timer/Alarm that initially fires every second for 60
seconds
after that it should only fire every minute for 60 minutes
after that it should only fire every hour for 24 hours
after this it should simply read "Updated ages ago"

Can someone help me with this? Initially I tried to use a Timer to
accomplish this, it worked great accept for the over lapping effect I
explained above. I am now trying to use an AlarmManager but I don't
know how to pass it a reference to my AppWidget instance.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment