justin2000

Untitled

Oct 18th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.  
  2.  
  3.     public void ding() {
  4.         AlarmManager mAlarmManger = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  5.  
  6.         //Create pending intent & register it to your alarm notifier class
  7.         Intent intent = new Intent(this, NotificationReceiver.class);
  8.         intent.putExtra("uur", "1e"); // if you want
  9.         PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
  10.  
  11.         //set timer you want alarm to work (here I have set it to 9.00)
  12.         Calendar calendar = Calendar.getInstance();
  13.         calendar.set(Calendar.DAY_OF_MONTH, 30);
  14.         calendar.set(Calendar.MONTH, 10);
  15.         calendar.set(Calendar.HOUR_OF_DAY, 9);
  16.         calendar.set(Calendar.MINUTE, 0);
  17.         calendar.set(Calendar.SECOND, 0);
  18.  
  19.         //set that timer as a RTC Wakeup to alarm manager object
  20.         mAlarmManger.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment