Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public void setAlarm() {
Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
mSender = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), mSender);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment