您好我正在尝试在Android中的特定时间生成通知。我能够生成通知,但它会立即生成,而我希望它稍后生成。任何人都可以建议我哪里出错。
calendar.set(Calendar.MONTH, 11);
calendar.set(Calendar.YEAR, 2016);
calendar.set(Calendar.DAY_OF_MONTH, 20);
calendar.set(Calendar.HOUR_OF_DAY, 2);
calendar.set(Calendar.MINUTE, 58);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.AM_PM, Calendar.PM);
long timeinmill = calendar.getTime().getTime() - System.currentTimeMillis();
Intent myIntent = new Intent(MakeAppointment.this, MyReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(MakeAppointment.this, 0, myIntent,0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC, timeinmill, pendingIntent);