Hey, how to set the alarm on Android AlarmManager for an urgent date (android alarmmanager set the alarm for the date) I was looking for all this. pay attention to the value of the month!
Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); //cal.add(Calendar.SECOND, 10); cal.set(Calendar.DATE,19); //1-31 cal.set(Calendar.MONTH,Calendar.DECEMBER); //first month is 0!!! January is zero!!! cal.set(Calendar.YEAR,2012);//year... cal.set(Calendar.HOUR_OF_DAY, 16); //HOUR cal.set(Calendar.MINUTE, 39); //MIN cal.set(Calendar.SECOND, 10); //SEC // Create a new PendingIntent and add it to the AlarmManager Intent intent = new Intent(MainActivity.this, alarmAct.class); PendingIntent pendingIntent = PendingIntent.getService(MainActivity.this, 0,intent, 0); //or if you start an Activity //PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0,intent, 0); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
source share