我怎样才能在android中重复闹钟,只在星期一,星期二和星期五

时间:2011-03-31 10:30:26

标签: android

如何才能在Android中仅在周一,周二和周五重复闹钟。

Intent myIntent = new Intent(getApplicationContext(), x.class);
            PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, myIntent, 0);

                        AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

                        //Calendar calender = new GregorianCalendar();
                        Calendar calender = Calendar.getInstance();
                        calender.setTimeInMillis(System.currentTimeMillis());
                        calender.set(Calendar.HOUR_OF_DAY, hours);
                        calender.set(Calendar.MINUTE, ireminder.getMin());
                        calender.set(Calendar.SECOND, 0);
                        calender.set(Calendar.MILLISECOND, 0);
                            calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,3);
                             calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,2);
                              calender.set(Calendar.DAY_OF_WEEK_IN_MONTH,6);
 alarmManager.set(AlarmManager.RTC_WAKEUP, calender.getTimeInMillis(), pendingIntent);

但它不会重复3天和6天(星期一,星期二和星期五) 你们能帮帮忙吗?

1 个答案:

答案 0 :(得分:0)

您需要设置3个单独的警报,或使您的警报接收器足够智能,以便在上一次触发时安排下一个警报。在上面的例子中,看起来只会使用“6”的值,因为它是最后一个值集。