, пожалуйста, помогите
val snoozeIntent = Intent(this, SnoozeReceiver::class.java).apply {
action = "ACTION_SNOOZE"
putExtra("EXTRA_NOTIFICATION_ID", 0)
}
Я пытаюсь следовать документации здесь: https://developer.android.com/training/notify-user/build-notification#Actions
мой класс вещания:
class SnoozeReceiver: BroadcastReceiver() {
private val REQUEST_CODE = 0
override fun onReceive(context: Context, intent: Intent) {
val triggerTime = SystemClock.elapsedRealtime() + DateUtils.MINUTE_IN_MILLIS
val notifyIntent = Intent(context, AlarmReceiver::class.java)
val notifyPendingIntent = PendingIntent.getBroadcast(
context,
REQUEST_CODE,
notifyIntent,
PendingIntent.FLAG_UPDATE_CURRENT
)
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
AlarmManagerCompat.setExactAndAllowWhileIdle(
alarmManager,
AlarmManager.ELAPSED_REALTIME_WAKEUP,
triggerTime,
notifyPendingIntent
)
val notificationManager = ContextCompat.getSystemService(
context,
NotificationManager::class.java
) as NotificationManager
notificationManager.cancelAll()
}
}
Android манифест:
<receiver
android:name=".receiver.SnoozeReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="ACTION_SNOOZE"/>
</intent-filter>
</receiver>