Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中设置更多警报?_Android - Fatal编程技术网

在Android中设置更多警报?

在Android中设置更多警报?,android,Android,我使用以下代码创建报警 String strDateTime=strDate+" "+strTime; DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date alarmTime = null; try { alarmTime = dfm.parse(strDateTi

我使用以下代码创建报警

String strDateTime=strDate+" "+strTime;             
            DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm");              
            Date alarmTime = null;
            try {
                alarmTime = dfm.parse(strDateTime);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            long setAlarmTime=alarmTime.getTime();

            Intent myIntent = new Intent(context, MyAlarmService.class);
            pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);

            AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

            //set time and get the Intent 
            alarmManager.set(AlarmManager.RTC_WAKEUP, setAlarmTime, pendingIntent);

如果我设置了多个报警,则将执行最后一个报警。如何在android中添加更多报警时间?

尝试在每个
AlarmManager.set
调用中为每个
Intent
(myIntent in code)提供一些随机数据(通过
setDat
a调用)


AlamManager
重置报警,之前设置为相同的
PendingEvent
(您的PendingEvents总是相同的)

尝试在每个
AlarmManager.set
调用中为每个
Intent
(myIntent in code)提供一些随机数据(通过
setDat
调用)

AlamManager
重置先前为相同的
PendingEvent设置的报警(您的PendingEvents始终相同)