2.Notification
Code:
main.kt
package com.example.notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
    var nchid="TYIT"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        createNotificationChannel()
        button.setOnClickListener {
            createNotification()
        }
    }
    fun createNotificationChannel(){
            if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
                var ch=NotificationChannel(nchid,"SRM",NotificationManager.IMPORTANCE_HIGH)
                var mg=getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
                mg.createNotificationChannel(ch)
            }
    }
    fun createNotification(){
        val i = Intent(this, whatsapp::class.java)
        val pi = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT )

        var n=NotificationCompat.Builder(this,nchid)
            .setSmallIcon(com.google.android.material.R.drawable.ic_clock_black_24dp)
            .setContentTitle("Whatsapp")
            .setContentText("You have new Message")
            .setPriority(NotificationManager.IMPORTANCE_HIGH)
            .setContentIntent(pi) 
            .build()
        NotificationManagerCompat.from(this).notify(1,n)
    }
}
whatsapp.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".whatsapp"> 
 <ImageView
        android:id="@+id/imageView"
        android:layout_width="287dp"
        android:layout_height="283dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/wtp2" />
</androidx.constraintlayout.widget.ConstraintLayout>
