Created
June 23, 2011 07:08
-
-
Save granoeste/1042070 to your computer and use it in GitHub Desktop.
[Android]Repeatedly running the Service in the Alarm Manager
This file contains 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
Intent serviceIntent = new Intent(this, MyService.class); | |
PendingIntent pendingIntent | |
= PendingIntent.getService(this, 0, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); | |
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); | |
am.setInexactRepeating ( | |
AlarmManager.RTC, | |
System.currentTimeMillis(), | |
//AlarmManager.INTERVAL_HOUR, | |
AlarmManager.INTERVAL_FIFTEEN_MINUTES, | |
pendingIntent); |
This file contains 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
Intent serviceIntent = new Intent(this, MyService.class); | |
PendingIntent pendingIntent | |
= PendingIntent.getService(this, 0, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); | |
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); | |
am.cancel(pendingIntent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment