我需要每天重複報警。這就是我一次觸發鬧鐘的方式。如何在Android中重複鬧鐘?
public void clicker (View view)
{
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(AddAlarm.this,new TimePickerDialog.OnTimeSetListener()
{
@Override
public void onTimeSet(TimePicker timePicker,
int selectedHour, int selectedMinute)
{
calendar.set(Calendar.HOUR_OF_DAY, selectedHour);
calendar.set(Calendar.MINUTE, selectedMinute);
int c_hour,c_min;
String format;
c_hour=selectedHour;
c_min=selectedMinute;
if (c_hour == 0) {
c_hour += 12;
format = "AM";
} else if (c_hour == 12) {
format = "PM";
} else if (c_hour > 12) {
c_hour -= 12;
format = "PM";
} else {
format = "AM";
}
String formatTime = String.format("%02d : %02d %s", c_hour, c_min, format);
TextView dimple = (TextView)findViewById(R.id.timeText);
dimple.setText(formatTime);
setAlarm(calendar);
}
}, hour, minute, false);
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
private void setAlarm(Calendar targetCal)
{
Intent alarmintent = new Intent(AddAlarm.this, AlarmReceiver.class);
alarmintent.putExtra("ALARM_NO", tempx);
alarmintent.setAction("my.action.string");
PendingIntent sender = PendingIntent.getBroadcast(AddAlarm.this, pen, alarmintent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), sender);
}
現在應該如何更改我的代碼來每天重複觸發警報?我怎樣才能殺死鬧鐘呢?謝謝,