Prevent user from dismissing notification

后端 未结 3 1438
無奈伤痛
無奈伤痛 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:51

    Use the flag,FLAG_ONGOING_EVENT to make it persistent.

    Notification notification = new Notification(icon, tickerText, when);
        notification.flags = Notification.FLAG_ONGOING_EVENT;
    

    Also you can check, FLAG_NO_CLEAR

提交回复
热议问题