我想在特定的日期和時間在android中設置我的通知,我正在通過在java中使用日期來嘗試它,但是我的通知在時間之前被觸發。所以我可以在指定的時間內讓它開火。提前致謝!如何在自定義時間開始通知?
這裏是我的通知代碼:
Calendar cal = java.util.Calendar.getInstance();
cal.set(2012, 00, 30);
Date date = cal.getTime();
date.setHours(17);
date.setMinutes(30);
date.setSeconds(15);
long time = date.getTime();
Log.e("date is",""+date);
long when = time;
Notification notification = new Notification(notificationIcon,tickerText,date.getTime());
notification.when = date.getTime();
RemoteViews contentView = new RemoteViews("com.LayoutDemo",R.layout.userscreen);
notification.contentView= contentView;
Intent intent = this.getIntent();
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.contentIntent= contentIntent;
notification.flags= Notification.FLAG_AUTO_CANCEL;
int NOTIFICATION_ID =1;
nManager.notify(NOTIFICATION_ID,notification);
好,謝謝!待定你有關於如何開始播種通知服務的任何想法嗎? – 2012-01-30 12:29:24