У меня есть список программ EPG, расписание программ, и я хочу отправлять уведомления в зависимости от времени программы. Если программа в 6:00, то уведомление также в 6:00
Код уведомления
@RequiresApi(api = Build.VERSION_CODES.O)
void makeNotificationChannel(String id, String name, int importance) {
NotificationChannel channel = new NotificationChannel(id, name, importance);
channel.setShowBadge(true); // set false to disable badges, Oreo exclusive
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
assert notificationManager != null;
notificationManager.createNotificationChannel(channel);
}
void issueNotification() {
// make the channel. The method has been discussed before.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
makeNotificationChannel("CHANNEL_1", "Example channel", NotificationManager.IMPORTANCE_DEFAULT);
}
// the check ensures that the channel will only be made
// if the device is running Android 8+
PendingIntent contentIntent =
PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
NotificationCompat.Builder notification =
new NotificationCompat.Builder(this, "CHANNEL_1");
// the second parameter is the channel id.
// it should be the same as passed to the makeNotificationChannel() method
notification
.setSmallIcon(R.mipmap.ic_launcher_logo) // can use any other icon
.setContentTitle("Notification!")
.setContentText("This is an Oreo notification!")
.setNumber(3)
.setContentIntent(contentIntent); // this shows a number in the notification dots
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
assert notificationManager != null;
notificationManager.notify(1, notification.build());
// it is better to not use 0 as notification id, so used 1.
Log.d("this", "error:::" + notificationManager);
}