Created
January 10, 2018 09:49
-
-
Save wangerekaharun/8214a9d6e44331b111bf2c3a9ec8216e to your computer and use it in GitHub Desktop.
Schedule an alarm that repeats every 15 minutes
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 toastIntent= new Intent(getApplicationContext(),ToastBroadcastReceiver.class); | |
PendingIntent toastAlarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, toastIntent,PendingIntent.FLAG_UPDATE_CURRENT); | |
long startTime=System.currentTimeMillis(); //alarm starts immediately | |
AlarmManager backupAlarmMgr=(AlarmManager)this.getSystemService(Context.ALARM_SERVICE); | |
backupAlarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,startTime,AlarmManager.INTERVAL_FIFTEEN_MINUTES,toastAlarmIntent); // alarm will repeat after every 15 minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment