Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. Calendar calendar = Calendar.getInstance();
  2. Calendar notifocationtime = Calendar.getInstance();
  3. int today = calendar.get(Calendar.DAY_OF_WEEK);
  4. int daynum = Days.indexOf(Day.getText().toString());
  5. if (today > daynum){
  6. notifocationtime.set(Calendar.DAY_OF_WEEK, (today - daynum));
  7. }
  8. else {
  9. notifocationtime.set(Calendar.DAY_OF_WEEK, (7 - (today - daynum)));
  10. }
  11. int nowH = calendar.get(Calendar.HOUR);
  12. char[] t = Hour.getText().toString().toCharArray();
  13. int Shour = Integer.valueOf(t[0])*10 + Integer.valueOf(t[1]);
  14. if (nowH > Shour){
  15. notifocationtime.set(Calendar.HOUR, (nowH - Shour));
  16. }
  17. else {
  18. notifocationtime.set(Calendar.HOUR, (24 - (nowH - Shour)));
  19. }
  20. int nowM = calendar.get(Calendar.HOUR);
  21. char[] MIN = Hour.getText().toString().toCharArray();
  22. int SMIN = Integer.valueOf(t[3])*10 + Integer.valueOf(t[4]);
  23. if (nowH > Shour){
  24. notifocationtime.set(Calendar.MINUTE, (nowM - SMIN) - 5);
  25. }
  26. else {
  27. notifocationtime.set(Calendar.MINUTE, (60 - (nowM - SMIN) - 5));
  28. }
  29. Intent intent = new Intent(getContext(),AlarmReciverService.class);
  30. intent.putExtra("title",ShowTIT);
  31. AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(ALARM_SERVICE);
  32. PendingIntent intent1 = PendingIntent.getBroadcast(getContext(), 0, intent, 0);
  33. alarmManager.set(AlarmManager.RTC_WAKEUP, notifocationtime.getTimeInMillis(), intent1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement