我想添加一个 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);
// ...
}