Reputation:
I have set up an alarm to run a service to grab events from the internet. The following is how I implemented it however it seems to run immediately and not delay the alarm at all.
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.currentThreadTimeMillis()+30000, AlarmManager.INTERVAL_DAY, newsAlarm);
Upvotes: 0
Views: 191
Reputation: 10908
Check the AlarmManager documentation, I think you might want to use:
am.setRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis()+30000, AlarmManager.INTERVAL_DAY, newsAlarm);
Upvotes: 1
Reputation: 46844
I think you want SystemClock.currentTimeMillis()
, not currentThreadTimeMillis()
The thread time is the number of millis since the thread was created. I think you want a real time in this context.
Upvotes: 1