Example code for notification in foreground service Here we are starting the foreground service from the MainActivity.kt //Start foreground service using notification channel id button.setOnClickListener { val intent = Intent(this, ForeGrService::class.java) intent.putExtra("extraText", editText.text.toString()) // startService(intent) //or ContextCompat.startForegroundService(this, intent) } Stop the service from the Activity class btn_stop.setOnClickListener { val intent: Intent = Intent(this, ForeGrService::class.java) stopService(intent) } onStartComment override method will trigger the notification using channel id in ForegroundService class override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val extraText = intent?.getStringExtra("extraText"); if(Build.VERSION.SDK_INT >= Build.VER...