我正在嘗試鬧鈴,響鈴數次。我的代碼如下。我能夠正確地獲取條目,但完全沒有警報響起。多個警報不響鈴
public void setAlert(View view) {
int h[] = new int[TOTAL_ALARMS];
int m[] = new int[TOTAL_ALARMS];
Intent intent[] = new Intent[TOTAL_ALARMS];
PendingIntent pendingIntent[] = new PendingIntent[TOTAL_ALARMS];
int piID = 12345;
Calendar[] cal = new Calendar[TOTAL_ALARMS];
for (int i = 0; i < TOTAL_ALARMS; i++) {
cal[i] = Calendar.getInstance();
}
for (int i = 0; i < TOTAL_ALARMS; i++) {
try {
m[i] = Integer.parseInt(editHour[i].getText().toString());
h[i] = Integer.parseInt(editMinute[i].getText().toString());
cal[i].set(Calendar.HOUR, h[i]);
cal[i].set(Calendar.MINUTE, m[i]);
intent[i] = new Intent(this, AlarmService.class);
pendingIntent[i] = PendingIntent.getActivity(this,
piID++, intent[i], PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,
cal[i].getTimeInMillis(), pendingIntent[i]);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
} catch (Exception ex) {
ex.printStackTrace();
System.out.print("OOPS!");
}
}
}
我已經在清單 – tanvi 2012-07-06 18:00:14
的接收機我已經在回答給予更多的建議,你也會嘗試過? – AAnkit 2012-07-06 18:01:24
ü正在使用getActivity,嘗試使用getReceiver – AAnkit 2012-07-06 18:02:38