Android 推送通知 - 在满足条件之前不可删除推送通知

Android Push Notification - Irremovable Push Notification Untill Condition Has Been Fulfilled

我想在 Android 中制作一个本地推送通知,不能通过简单地向右滑动来删除。应事先满足应用程序中的条件。这可能吗?如果可以,我该怎么做?

是的,你可以做到。

Use FLAG_ONGOING_EVENT

http://developer.android.com/reference/android/app/Notification.html#FLAG_ONGOING_EVENT

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

Use FLAG_NO_CLEAR

http://developer.android.com/reference/android/app/Notification.html#FLAG_NO_CLEAR