我正在尝试创建一个通知,该通知将显示在通知栏的"正在进行"区域(如WeatherBug).
这是我正在使用的代码:
PendingIntent intent = PendingIntent.getActivity(lastContext, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)
Run Code Online (Sandbox Code Playgroud)
根据我的理解,FLAG_NO_CLEAR也应该通过按下清除按钮来防止通知被清除,这也是行不通的
任何提示SO?
这是因为您在错误的位置使用标志.
你应该这样做:
notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
Run Code Online (Sandbox Code Playgroud)
在创建Notification对象之后和调用之前NotificationManager#notify
| 归档时间: |
|
| 查看次数: |
1311 次 |
| 最近记录: |