我想根据用户输入的分钟列表设置一堆闹钟。如果他们在下午4:00点击开始时钟按钮并设置了5分钟,10分钟和15分钟的闹钟,则需要设置为4点05分,4点10分和4点15分的闹钟。该代码我有seeeems权利和吐司派我来我都在列表中的每个项的“设置报警”的消息,但没有报警我的手机上都会响起:使用AlarmManager设置多个闹钟,一切正常,但没有闹钟
setAlarm.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] spAlarms = allAlarms.split(";");
for(int i = 0; i < spAlarms.length; i++) {
try {
if(!spAlarms.equals("")) {
int time = Integer.valueOf(spAlarms[i]);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, time);
Intent intent = new Intent(Hop_Timer.this, Alarm_Receiver.class);
intent.putExtra("alarm_message", "Time for your " + spAlarms[i] + " min addition!");
PendingIntent sender = PendingIntent.getBroadcast(Hop_Timer.this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
Toast.makeText(getApplicationContext(), "Set alarm", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
});
谢谢,但有人降级我的答案。 – AndroGeek 2014-11-24 13:11:01