Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AlarmManager
public static void setAlarm(Context context) {
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
SessionManager manager = new SessionManager(context);
int minutos = manager.getInt(context.getString(R.string.pref_key_actualizacion));
if (minutos == 0) {
minutos = 1;
}
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime(),
minutos * 60000, // 60000 = 1 minute,
pendingIntent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.