相关疑难解决方法(0)

NotificationCompat 4.1 SetSmallIcon和SetLargeIcon

我使用这个简单的代码在Android 4.1或更高版本中设置通知.它工作得很好,但我的问题是SmallIcon和LargeIcon.我知道SmallIcon显示在状态栏中,LargeIcon显示在下拉列表中.

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setTicker("The ticker");
builder.setContentTitle("The title");
builder.setContentText("The text");
builder.setSmallIcon(R.drawable.my_small_icon);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.my_96px_large_icon);
builder.setLargeIcon(bm);       
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify("direct_tag", NOTIF_ALERTA_ID, builder.build());
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 启动通知后,"The Ticker"文本旁边会显示一个裁剪的超大小图标,而不是显示原始SmallIcon而不会过大. 在此输入图像描述

  2. 在下拉列表中,我看到左边的LargeIcon,这很好.但是我也会在通知时间旁边看到右边的小图标.我不想表明这一点. 在此输入图像描述

notifications icons android

36
推荐指数
3
解决办法
6万
查看次数

NotificationCompat android - 如何只显示大图标而不是小

当我添加通知时:

        NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(this)  
              .setSmallIcon(R.drawable.plus)
.setContentTitle(title)
.setAutoCancel(true) 
.setContentText(text)
.setSound(RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setLargeIcon(bm);
Run Code Online (Sandbox Code Playgroud)

我看到大图标和小图标: 在此输入图像描述

如何只设置大图标,不小.如果只使用setLargeIcon,我根本看不到通知,只是声音警报.

notifications android

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×2

notifications ×2

icons ×1