execute service at particular time android
I am making GPS tracker application, and after 1 hrs I got the updated data and store into data base. then 开发者_JS百科at 12AM I want to send all data to particular email ID. So what I have to use so it send email at 12AM only
Use an AlarmManager
. You set the time with:
setInexactRepeating (AlarmManager.RTC_WAKEUP,
triggerAtTime,
myIntent,
AlarmManager.INTERVAL_DAY)
http://developer.android.com/reference/android/app/AlarmManager.html
BTW, you do not want to execute a Service
at that time. You want your Service
to execute an Activity
.
There's a snippet with details on how to implement it here: Android: How to use AlarmManager
I actually answered before a similar question: how do i set an alarm manager to fire every on specific day of week and time in android?
精彩评论