Notification
Add permission in AndroidManifest.xml
Section titled “Add permission in AndroidManifest.xml”<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />Create a notification manager
Section titled “Create a notification manager”val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManagerCreate a notification channel
Section titled “Create a notification channel”val channel = NotificationChannel( "channel_id", "channel_name", NotificationManager.IMPORTANCE_HIGH )
notificationManager.createNotificationChannel(channel)Create a notification
Section titled “Create a notification”val notification = NotificationCompat.Builder(context, channelId) .setContentTitle("hello") .setContentText("hello") .setSmallIcon(R.drawable.play) .build()Push the notification
Section titled “Push the notification”notificationManager.notify(<notificationId: Int>, notification)