Advertisement
michels10

Alarme Toda terça

Jun 25th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // ALARME TERÇA
  2. boolean alarmeTerca = (PendingIntent.getBroadcast(this, 0, new Intent("ALARME_DISPARADO_T"), PendingIntent.FLAG_NO_CREATE) == null);
  3. if(alarmeTerca){
  4. Log.i("Script", "Novo Alarme Terca");
  5.  
  6. Intent intent1 = new Intent("ALARME_DISPARADO_T");
  7. PendingIntent p1 = PendingIntent.getBroadcast(this, 0, intent1, 0);
  8. Calendar c1 = Calendar.getInstance();
  9. c1.setTimeInMillis(System.currentTimeMillis());
  10.  
  11. c1.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); // SUNDAY - MONDAY - TUESDAY - WEDNESDAY - THURSDAY - FRIDAY - SATURDAY
  12. c1.set(Calendar.HOUR_OF_DAY, 17); // 0 - 23
  13. c1.set(Calendar.MINUTE, 30); // 0 - 59
  14. c1.set(Calendar.SECOND, 0); // 0 - 59
  15. //c1.add(Calendar.SECOND, 3); // 0 - 59
  16.  
  17. AlarmManager alarme1 = (AlarmManager) getSystemService(ALARM_SERVICE);
  18. alarme1.setInexactRepeating(AlarmManager.RTC_WAKEUP, c1.getTimeInMillis(), 604800000, p1);
  19. //604800000(7d) 86400000(1d) 3600000(1h)
  20. }
  21. else{
  22. Log.i("Script", "AlarmeTerca já ativo");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement