Android 持续通知
我正在尝试创建一个通知,该通知将出现在通知栏的“正在进行”区域(如WeatherBug) 以下是我正在使用的代码:Android 持续通知,android,Android,我正在尝试创建一个通知,该通知将出现在通知栏的“正在进行”区域(如WeatherBug) 以下是我正在使用的代码: PendingIntent intent = PendingIntent.getActivity(lastContext, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR) 据我所知,FLAG_NO_C
PendingIntent intent = PendingIntent.getActivity(lastContext, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)
据我所知,FLAG_NO_CLEAR也应通过按下CLEAR(清除)按钮防止通知被清除,这也不起作用
有什么提示吗?这是因为您在错误的位置使用了标志 你应该做:
notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
在创建
通知
对象之后和调用通知管理器#通知
之前,这是因为您在错误的位置使用了标志
你应该做:
notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
创建通知
对象后,调用通知管理器#通知