Answers for "restart notification listener service"

4

restart notification listener service

You can use broadcast reciever for notify or cancel


//in your notificaitonListener service
 private var stateReceiver = object : BroadcastReceiver() {
        override fun onReceive(context: Context?, intent: Intent?) {
            when (intent?.action) {
                "update" -> {
                    notification()
                }
                "delete" -> {

                }
            }

        }
    }
 
 //this for activity or fragment 
 	 Timer().schedule(1500) {
       delay for notification service may be not start in application start
            val stateNotification = Intent("update")
            requireActivity().sendBroadcast(stateNotification)
     }
Posted by: Guest on October-07-2021

Browse Popular Code Answers by Language