I want to show a notification every day at the same time, I was able to show a notification at a time, but when it arrives at the same time again it does not appear
MyActivity
Calendar cal = Calendar.getInstance();
Date data1 = cal.getTime();
cal.set(Calendar.HOUR_OF_DAY, 19);
cal.set(Calendar.MINUTE, 55);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date data2 = cal.getTime();
if (data1.compareTo(data2) != 1) {
Intent intent = new Intent(this, AlarmReceiverActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
} else {
Log.e("Else", "Entrou");
}
AlarmReceiverActivity
int notificationId = 001;
Intent viewIntent = new Intent(this, MyActivity.class);
viewIntent.putExtra("notificacao", "2");
PendingIntent viewPendingIntent =PendingIntent.getActivity(this, 0, viewIntent, 0);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.logo)
.setContentTitle("")
.setContentText("Que tal da uma olhada nas suas tarefas agora?")
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))//RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setContentIntent(viewPendingIntent);
NotificationManagerCompat notificationManager =NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, notificationBuilder.build());
finish();