'How would I pass a string so the notification actually has the reminder message?

Making basic reminder app. Can't figure out how to pass the actually reminder text so the notification actually displays the reminder instead of just having a blank notification.

In MainActivity, where alarm created

private fun startAlarm (cal : Calendar) {
        val alarmManager: AlarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager

        val intent :Intent = Intent(this, AlertReceiver().javaClass)
        val pendingIntent : PendingIntent = PendingIntent.getBroadcast(this, reqCode, intent, 0)

        alarmManager.setExact(AlarmManager.RTC_WAKEUP, cal.timeInMillis, pendingIntent)
}

AlertReceiver

class AlertReceiver(): BroadcastReceiver() {
    @RequiresApi(Build.VERSION_CODES.O)
    override fun onReceive(context: Context?, intent: Intent?) {
        val notificationObj : Notification = Notification(context)
        val notif : NotificationCompat.Builder = notificationObj.createNotification("")

        notificationObj.getManager().notify(1, notif.build())
    }

}

Notification, createNotification

    fun createNotification(reminder: String): NotificationCompat.Builder{
        //to load main screen when click notification
        val main: Intent = Intent (this, MainActivity().javaClass).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK and Intent.FLAG_ACTIVITY_CLEAR_TASK
        }
        val pendingMain: PendingIntent = PendingIntent.getActivity(this, 0, main, 0)
        val notif : NotificationCompat.Builder = NotificationCompat.Builder(applicationContext, channelID)
            .setSmallIcon(R.drawable.ic_android_black_24dp)
            .setContentTitle("Reminder:")
            .setContentText(reminder)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setContentIntent(pendingMain)
            .setAutoCancel((true))

        return notif
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source