Created
November 21, 2020 23:17
-
-
Save oscarito9410/3e869ceea2daf47e9ee071b99a259275 to your computer and use it in GitHub Desktop.
AlarmManager
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
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