in

Android studio notifications


I have a problem with notifications in my app. I want to set multiple notifications for different hours of the day. For example, let’s take 8, 12 and 23 o’clock. But only the one at 23 o’clock triggers every day. What’s wrong with my code and will it work even if the app is killed?
Here’s the code that sets alarms in my activity

public void myAlarm(int hour, int minute) {

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, 0);


    Intent intent = new Intent(getApplicationContext(), Reminder.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    if (alarmManager != null) {
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
    }
}

and this is what I wrote in onCreate

        myAlarm(8, 0);
        myAlarm(12, 0);
        myAlarm(23, 0);

this is my receiver

public class Reminder extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {
    Intent in = new Intent(context, MySecoundActivity.class);
    in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, in, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "Reminder")
            .setSmallIcon(R.drawable.bell)
            .setContentTitle("Notification!")
            .setContentText("Text of notification")
            .setColor(0xfb3ff)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .setPriority(NotificationCompat.PRIORITY_HIGH);


    NotificationManagerCompat notificationMngr = NotificationManagerCompat.from(context);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CharSequence name = "Reminder";
        String description = "reminder channel";
        int importance = NotificationManager.IMPORTANCE_HIGH;
        NotificationChannel channel = new NotificationChannel("Reminder", name, importance);
        channel.setDescription(description);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(channel);

    }
    notificationMngr.notify(200, builder.build());
}



Source: https://stackoverflow.com/questions/70555802/android-studio-notifications

All action icons for each class/job are blended together to create new backgrounds for each job/class icon

Russian Telecom Operators Deploying 5G NSA: Moscow Govt Minister