Tôi muốn đặt thông báo của mình trong android vào ngày và giờ cụ thể, tôi đang cố gắng thông báo bằng cách sử dụng ngày trong java, nhưng thông báo của tôi được kích hoạt trước thời gian. vì vậy tôi có thể làm gì để kích hoạt nó vào thời gian được chỉ định. Cảm ơn trước!Làm cách nào để bắt đầu thông báo vào thời gian tùy chỉnh?
Đây là mã của tôi để thông báo:
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);
Ok thanks !! Bạn có bất kỳ ý tưởng về làm thế nào để bắt đầu dịch vụ để gieo thông báo? –