无法显示多个余数

时间:2013-08-20 14:08:11

标签: android android-calendar

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


(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();
}

2 个答案:

答案 0 :(得分:1)

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

Reminder Application example

答案 1 :(得分:0)

您正在设置notificationManager.notify(通知++,通知);用++? 基本上,你自己设置为2