0

我想添加一个 Notificationmanager,它应该在几毫秒后启动。一切都在运行,但我仍然不知道如何添加通知在几周后出现的时间?

public void test(){
    int icon = R.drawable.ic_launcher;
    CharSequence ticker ="ticker";
    long showAt =System.currentTimeMillis();
    Notification notification = new Notification(icon, ticker, showAt);activity/intent
    CharSequence notificationTitle = "test";
    CharSequence notificationMessage = "Test1";
    Intent intent = new Intent(this, Activity.class);
    PendingIntent objPendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
    Context ctx = getApplicationContext();
    notification.setLatestEventInfo(ctx, notificationTitle, notificationMessage, objPendingIntent);
    final int notificationIdentifier = 101; //an unique number set by developer to identify a notification, using this notification can be updated/replaced
    NotificationManager notificationManager = (NotificationManager)
            getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(notificationIdentifier, notification);
    // ... 
}
4

1 回答 1

1

您需要使用带有通知的警报管理器,以便在固定时间间隔后重复您的通知。查看AlarmManagerNotificationManagerTutorialAndroid AlarmManager 教程Multiple Notifications Using AlarmManager。那里有很多教程。希望这可以帮助。

于 2013-08-02T00:43:31.713 回答