Last active
December 24, 2015 13:49
-
-
Save funkyidol/6808240 to your computer and use it in GitHub Desktop.
Starting Service at specific intervals controlled using AlarmManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar cal = Calendar.getInstance(); | |
Intent intent = new Intent(this, MyService.class); | |
PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0); | |
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE); | |
// Start every 30 seconds | |
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, pintent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment