我对快速报警有点问题。
如果我将闹钟时间设置在正常的“快速闹钟”之前,闹钟可以正常工作。我如何设置闹钟,例如晚上 8:00,晚上 7:55 的快速闹钟,这种工作方式不同,不会打开
private void showQuickAlarmDialog() {
View layout = mFactory.inflate(R.layout.quick_alarm_dialog, null);
final TextView text1 = (TextView) layout
.findViewById(android.R.id.text1);
final SeekBar slider = (SeekBar) layout
.findViewById(android.R.id.input);
int last_snooze = mPrefs.getInt(PREF_LAST_QUICK_ALARM, 0);
slider.setMax(59);
slider.setProgress(last_snooze);
text1.setText(AlarmClock.this.getString(R.string.minutes,
String.valueOf(last_snooze + 1)));
slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seek, int value,
boolean fromTouch) {
text1.setText(AlarmClock.this.getString(R.string.minutes,
String.valueOf(value + 1)));
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
});
AlertDialog d = new AlertDialog.Builder(this)
.setTitle(R.string.quick_alarm)
.setView(layout)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
int snooze_min = slider.getProgress() + 1;
long snoozeTarget = System.currentTimeMillis()+ 1000 * 60 * snooze_min;
Alarms.calculateNextAlert(AlarmClock.this).getAlert();
//if (nextAlarm > snoozeTarget) {
//alarm will fire before snooze will...
//}
//else {
Alarms.saveSnoozeAlert(
AlarmClock.this,0,snoozeTarget,AlarmClock.this.getString(R.string.quick_alarm));
Alarms.setNextAlert(AlarmClock.this);
Toast.makeText(
AlarmClock.this,
getString(
R.string.alarm_alert_snooze_set,
snooze_min),
Toast.LENGTH_LONG).show();
updateSnoozeVisibility();
mPrefs.edit()
.putInt(PREF_LAST_QUICK_ALARM,
snooze_min - 1).commit();
// }
}
}).show();
}
private void updateSnoozeVisibility() {
long next_snooze = mPrefs.getLong(Alarms.PREF_SNOOZE_TIME, 0);
View v = (View) findViewById(R.id.snooze_message);
if (next_snooze != 0) {
TextView tv = (TextView) v.findViewById(R.id.snooze_message_text);
Calendar c = new GregorianCalendar();
c.setTimeInMillis(next_snooze);
String snooze_time = Alarms.formatTime(AlarmClock.this, c);
tv.setText(getString(R.string.snooze_message_text, snooze_time));
v.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
Alarms.disableSnoozeAlert(AlarmClock.this);
Toast.makeText(AlarmClock.this,
getString(R.string.snooze_dismissed),
Toast.LENGTH_LONG).show();
Alarms.setNextAlert(AlarmClock.this);
}
});
v.setVisibility(View.VISIBLE);
} else {
v.setVisibility(View.GONE);
}
}
private void updateEmptyVisibility() {
View v = findViewById(R.id.alarms_list_empty);
if (v != null)
v.setVisibility(mAlarmsList.getAdapter().getCount() < 1 ? View.VISIBLE
: View.GONE);
}
一句话。如果稍后设置正常警报,我将无法打开快速警报。