Skip to content

Instantly share code, notes, and snippets.

@granoeste
Created June 23, 2011 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granoeste/1042070 to your computer and use it in GitHub Desktop.
Save granoeste/1042070 to your computer and use it in GitHub Desktop.
[Android]Repeatedly running the Service in the Alarm Manager
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);
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