gpt4 book ai didi

Android Notification.Builder : show a notification without icon

转载 作者:可可西里 更新时间:2023-11-01 19:12:41 30 4
gpt4 key购买 nike

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

int icon = R.drawable.ic_notification_icon;
android.app.Notification.Builder nbuilder = new Notification.Builder(this);

nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
nbuilder.setContentText(msg);
nbuilder.setOnlyAlertOnce(true);
nbuilder.setOngoing(true);
nbuilder.setSmallIcon(icon,level.level);

如何隐藏或完全删除 smallIcon?我试过不使用nbuilder.setSmallIcon,结果通知根本不显示!

最佳答案

在 Jelly Bean 和更高版本上,您可以使用 nbuilder.setPriority(Notification.PRIORITY_MIN);此优先级的确切解释留给系统 UI,但在 AOSP 中,这会导致隐藏通知的图标。

这适用于不需要引起用户注意的“环境”或“背景”信息,但如果用户碰巧在通知面板周围四处闲逛,她可能会感兴趣。查看Notifications section of the Android Design site有关如何最好地使用通知优先级的更多信息。

关于Android Notification.Builder : show a notification without icon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16170648/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com