简体   繁体   English

Android-带有小图标的通知栏

[英]Android - Notification Bar with No Small Icon

I have written an app, that has to have push notifications. 我已经编写了一个应用程序,该应用程序必须具有推送通知。 As you know, notifications have a large icon and a small icon. 如您所知,通知有一个大图标和一个小图标。 The large icon is showed when you pull down the notification bar, and the small icon is showed when the notification bar is up on top of the screen. 下拉通知栏时会显示大图标,而通知栏在屏幕上方时会显示小图标。 My problem is, I do not want to have a small icon so that the user only sees my notification when they pull down the notification bar. 我的问题是,我不想有一个小图标,以便用户仅在下拉通知栏时才能看到我的通知。 There are a couple of answers to this question on StackOverFlow, but they all suggest making the small icon the transparent color. 在StackOverFlow上有两个针对此问题的答案,但都建议将小图标设置为透明颜色。 Yes, when you make it transparent, it seems to be no longer visible in the notification bar, but it's actually still there. 是的,当您将其设置为透明时,它似乎在通知栏中不再可见,但实际上仍然存在。 Let's say another app on the device pushes a notification, and then your app pushes its notification. 假设设备上的另一个应用程序推送了通知,然后您的应用程序推送了通知。 In this case, your icon is "invisible" but because their notification was pushed first, their notification doesn't show up in the most left up corner of the screen. 在这种情况下,您的图标是“不可见的”,但是由于他们的通知被首先推送,因此他们的通知不会显示在屏幕的最左上角。 This is because your small icon is there, it is just transparent. 这是因为您的小图标在那里,它只是透明的。 Here is my code that pushes the notification. 这是我推送通知的代码。

NotificationCompat.Builder mBuilder =
            (NotificationCompat.Builder) new NotificationCompat.Builder(this)
                    .setLargeIcon(bitmap)
                    .setSmallIcon(getNotificationIcon())
                    .setAutoCancel(true)
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(show))
                    .setContentTitle(show)
                    .setOngoing(true)
                    .setContentIntent(resultPendingIntent)
                    .setContentText(timeUpdater.getCurrentDate());

    NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    mNotificationManager.notify(101, mBuilder.build());

EDIT: I am currently using a small icon since I could not find a solution. 编辑:我目前正在使用一个小图标,因为我找不到解决方案。

This will Help you. 这将为您提供帮助。

For nice-to-know background information that isn't aimed specifically at the user. 对于不是专门针对用户的背景信息。 For example, weather or nearby places of interest. 例如,天气或附近的名胜古迹。

.setPriority(Notification.PRIORITY_MIN)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM