Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calendar calendar = Calendar.getInstance();
- Calendar notifocationtime = Calendar.getInstance();
- int today = calendar.get(Calendar.DAY_OF_WEEK);
- int daynum = Days.indexOf(Day.getText().toString());
- if (today > daynum){
- notifocationtime.set(Calendar.DAY_OF_WEEK, (today - daynum));
- }
- else {
- notifocationtime.set(Calendar.DAY_OF_WEEK, (7 - (today - daynum)));
- }
- int nowH = calendar.get(Calendar.HOUR);
- char[] t = Hour.getText().toString().toCharArray();
- int Shour = Integer.valueOf(t[0])*10 + Integer.valueOf(t[1]);
- if (nowH > Shour){
- notifocationtime.set(Calendar.HOUR, (nowH - Shour));
- }
- else {
- notifocationtime.set(Calendar.HOUR, (24 - (nowH - Shour)));
- }
- int nowM = calendar.get(Calendar.HOUR);
- char[] MIN = Hour.getText().toString().toCharArray();
- int SMIN = Integer.valueOf(t[3])*10 + Integer.valueOf(t[4]);
- if (nowH > Shour){
- notifocationtime.set(Calendar.MINUTE, (nowM - SMIN) - 5);
- }
- else {
- notifocationtime.set(Calendar.MINUTE, (60 - (nowM - SMIN) - 5));
- }
- Intent intent = new Intent(getContext(),AlarmReciverService.class);
- intent.putExtra("title",ShowTIT);
- AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(ALARM_SERVICE);
- PendingIntent intent1 = PendingIntent.getBroadcast(getContext(), 0, intent, 0);
- alarmManager.set(AlarmManager.RTC_WAKEUP, notifocationtime.getTimeInMillis(), intent1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement