0

我正在开发小型提醒应用程序,它工作正常,但我的问题是我要添加多个提醒


(1) 2013 年 8 月 20 日 - 7(小时)-35(分钟)
(2) 2013 年 8 月 20 日 - 7(小时)-36(分钟)

我的提醒应用程序只显示第二个从不显示第一个。

我的源代码:

获取时间和消息:

public void onDateSelectedButtonClick(View v) {
    int day = datePicker.getDayOfMonth();
    int month = datePicker.getMonth();
    int year = datePicker.getYear();
    int hour = timePicker.getCurrentHour();
    int minute = timePicker.getCurrentMinute();
    message = message_text.getText().toString();
    title = title_text.getText().toString();
    Toast.makeText(getApplicationContext(), message+ ""+title, Toast.LENGTH_LONG).show();
    Calendar calender = Calendar.getInstance();
    calender.set(year, month, day,hour,minute,0);
    ScheduleClient.setAlarmForNotification(calender);
    Toast.makeText(getApplicationContext(), "Notification of day"+ day+"/"+ month, Toast.LENGTH_LONG).show();

}

当时显示信息:

private static int NOTIFICATION = 1;
private void showNotification() {
    CharSequence title = "Alarm";
    int icon = R.drawable.ic_launcher;
    CharSequence text = "Notification";
    long time = System.currentTimeMillis();
    Notification notification = new Notification(icon,text,time);
    Intent intent = new Intent(this,ShowActivity.class);
    String body = TaskReminder.title;
    String message = TaskReminder.message;
    intent.putExtra("title", body);
    intent.putExtra("message", message);
    PendingIntent pi= PendingIntent.getActivity(this, NOTIFICATION, intent, 0);
    notification.setLatestEventInfo(this, title, text, pi);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(NOTIFICATION++, notification);
    stopSelf();
}
4

2 回答 2

1

您可以参考此链接来创建提醒应用程序。它将为您的期望提供解决方案。

提醒应用示例

于 2013-08-20T18:27:53.467 回答
0

您正在设置 notificationManager.notify(NOTIFICATION++, notification); 有一个++?本质上,您自己将其设置为 2

于 2013-08-20T15:50:30.833 回答