![](/img/trans.png)
[英]Android: How to adjust the largeIcon of a NotificationCompat.Builder in the bounds of the notification
[英]Android how to hide NotificationCompat.Builder notification`s icon on status bar?
我的問題很簡單,但我無法解決它很長一段時間,所以我在這里問。
如何隱藏狀態欄中顯示的正在進行的通知圖標? 我正在使用NotificationCompat.Builder
對象創建通知。 我試圖跳過(當取消選中顯示圖標的選項時) builder.setSmallIcon()
函數調用,但這導致通知屏幕上沒有通知。
從Android 4.1(API 16)開始,可以指定通知的priority
。 如果將該標志設置為PRIORITY_MIN
,通知圖標將不會顯示在狀態欄上。
builder.setPriority(NotificationCompat.PRIORITY_MIN);
從Android 8.0 Oreo(API級別26)開始,您必須創建NotificationChannel
並將其importance
設置為IMPORTANCE_MIN
:
NotificationChannel channel =
new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MIN);
notificationManager.createNotificationChannel(channel);
...
builder.setChannelId(channel.getId());
如何隱藏狀態欄中顯示的正在進行的通知圖標?
你沒有。
我試圖跳過(當取消選中顯示圖標的選項時)builder.setSmallIcon()函數調用,但這導致通知屏幕中沒有通知。
正確。 由於提出Notification
的主要目的是在狀態欄中放置一個圖標,因此無法在狀態欄中放置圖標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.