android中的多个通知

时间:2010-09-06 10:20:31

标签: android

我想创建提醒应用程序...我正在使用通知管理器... 我使用这一行作为Notification的实例化...

long when=sdf.parse("09 06 2010 15:45:00");
Notification notifyDetails = new Notification(R.drawable.reminder_1,"Reminder",when.getTime());

我需要在指定的时间开始通知...但是这里是我在给出日期后立即开始的通知...并且还帮我显示多个通知

2 个答案:

答案 0 :(得分:3)

when参数是通知栏处于展开视图时显示的Notification的时间。在显示Notification时,它不用于计划。

如果您想安排将来发生的事情,请尝试the AlarmManager service

答案 1 :(得分:0)

String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager notificationManager = (NotificationManager) getSystemService(ns);
        int icon = R.drawable.update;
        CharSequence tickerText = "assignments";
        long when = System.currentTimeMillis();

        Notification assignmentNotification = new Notification(icon, tickerText, when);
        assignmentNotification.defaults |= Notification.DEFAULT_SOUND;
        long[] vibrate = {0,100,200,300};
        assignmentNotification.vibrate = vibrate;
        Context context = getApplicationContext();
        CharSequence contentTitle = "check assignments";
        CharSequence contentText = "chek ur app for assignments ";
        Intent notificationIntent = new Intent(context, ViewAssignmentnotificationActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,0);
        assignmentNotification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
       ** final int id = 2;

使用另一个“id”进行多次通知...