首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android推送通知:图标未在通知中显示,相反显示白色方框

Android推送通知:图标未在通知中显示,相反显示白色方框
EN

Stack Overflow用户
提问于 2015-06-12 04:42:16
回答 21查看 290.8K关注 0票数 244

我的应用程序生成一个通知,但我为该通知设置的图标没有显示。相反,我得到一个白色的正方形。

我试过调整图标的png大小(维度为720x720、66x66、44x44、22x22)。奇怪的是,当使用较小的尺寸时,白色方块就更小了。

我搜索了这个问题,以及生成通知的正确方法,从我所读到的内容来看,我的代码应该是正确的。可悲的是,事情并不像他们应该做的那样。

我的手机是带有Android5.1.1的Nexus 5。这个问题也出现在仿真器上,三星Galaxy 5.0.1的s4和Android5.0.1的摩托罗拉Moto (都是我借来的,现在还没有)。

通知代码如下,以及两个屏幕截图。如果您需要更多的信息,请随时索取。

谢谢你们所有人。

代码语言:javascript
运行
复制
@SuppressLint("NewApi") private void sendNotification(String msg, String title, String link, Bundle bundle) {
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Intent resultIntent = new Intent(getApplicationContext(), MainActivity.class);
    resultIntent.putExtras(bundle);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
    Notification notification;
    Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notificationsound);
    notification = new Notification.Builder(this)
                .setSmallIcon(R.drawable.lg_logo)
                .setContentTitle(title)
                .setStyle(new Notification.BigTextStyle().bigText(msg))
                .setAutoCancel(true)
                .setContentText(msg)
                .setContentIntent(contentIntent)
                .setSound(sound)
                .build();
    notificationManager.notify(0, notification);
}

EN

Stack Overflow用户

发布于 2015-06-12 04:55:47

根据谷歌的设计指南

通知图标必须是完全白色的。

票数 42
EN
查看全部 21 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30795431

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档