Android设置多个闹钟

//建立Intent和PendingIntent来调用闹钟管理器
Intent intent = new Intent(Alarm.this,AlarmReceiver.class);
//下面这行代码的第二个参数getBroadcast(Alarm.this, 0, intent, 0)就是区分闹钟的ID
PendingIntent pendingIntent = PendingIntent.getBroadcast(Alarm.this, 0, intent, 0);
//获取闹钟管理器
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
//设置闹钟
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 10*1000, pendingIntent);


你可能感兴趣的:(Android)