Mastering Android Development Update Interval

1 reply [Last post]
JohnMikes
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 05/17/2010

Hello, I have read, compiled and studied your code, and is working perfectly.
I would appreciate your input on a thought I have.
I see that the widget updates every second and that may impact the battery.I would like to update the widget every minute but exactly when the system clock changes.
I thought about changing in CountdownWidget class the following:
replace where it says
public static final int UPDATE_RATE = 1000;
to
Calendar calendar = new GregorianCalendar();
int second = calendar.get(Calendar.SECOND);
long millis =calendar.get(Calendar.MILLISECOND);
long secmil=second*1000+millis;
long UPDATE_RATE=60000-secmil;

But i am still missing something, because is not exactly synchronized to update every second with the clock at the notification bar.

Any help would be appreciated.
Thanks

pandorauk
User offline. Last seen 1 year 8 weeks ago. Offline
Joined: 12/07/2010
it is sometimes world of hard

it is sometimes world of hard to Pandora in a world of adults Pandora Bracelets