Created
January 10, 2018 09:50
-
-
Save wangerekaharun/6359d8e144a444842945ab4976376108 to your computer and use it in GitHub Desktop.
Create 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