Android 如何查找通知ID?
如何获取要清除的标题或通知ID。 我的应用程序会生成几个通知 空气污染指数为19Android 如何查找通知ID?,android,api,android-notifications,google-maps-android-api-2,Android,Api,Android Notifications,Google Maps Android Api 2,如何获取要清除的标题或通知ID。 我的应用程序会生成几个通知 空气污染指数为19 使用 NotificationListenerService有用吗?是的,您可以使用NotificationListenerService中的getActiveNotifications获取所有活动通知 StatusBarNotification[] activeNotifications = service.getActiveNotifications(); 然后遍历可用的通知并使用getId() 如果是由您创
使用
NotificationListenerService
有用吗?是的,您可以使用NotificationListenerService
中的getActiveNotifications
获取所有活动通知
StatusBarNotification[] activeNotifications = service.getActiveNotifications();
然后遍历可用的通知并使用getId()
如果是由您创建的,则可以缓存ID。
if(activeNotifications!=null){
for(StatusBarNotification notification : activeNotifications ){
if (notification.getId() == ID_TO_CHECK) {
// do your operation
}
}
}