Prevent user from dismissing notification

后端 未结 3 1456
無奈伤痛
無奈伤痛 2021-02-02 05:27

Some apps have notifications which can´t be dismissed by swiping them away.

How can I manage such behaviour?

3条回答
  •  无人及你
    2021-02-02 05:47

    I used the below code to make my notification persistent:

    startForeground(yourNotificationId,notificationObject);

    To make it dismissable, just do the below:

    stopForeground(true);

提交回复
热议问题