首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >通知中不显示图标:显示白色方块

通知中不显示图标:显示白色方块
EN

Stack Overflow用户
提问于 2018-04-20 08:13:53
回答 2查看 0关注 0票数 0

我的应用程序生成通知,但我为该通知设置的图标未显示。相反,我得到一个白色的广场。

我曾尝试调整图标的png(尺寸为720x720,66x66,44x44,22x22)。奇怪的是,当使用更小的尺寸时,白色方块更小。

我搜索了这个问题,以及生成通知的正确方式,并且从我读过的代码应该是正确的。可悲的是,事情并不像他们应该做的那样。

我的手机是Android 5.1.1的Nexus 5。问题也出现在模拟器上,Android 5.0.1版本的三星Galaxy S4以及Android 5.0.1版本的摩托罗拉Moto G(我都借用过,现在还没有)

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

@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用户

发布于 2018-04-20 18:10:17

我真的建议遵循Google的设计指南

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

以下是您可以如何实现它的方法:

如果您使用Gradle / Android Studio构建应用程序,请使用build.gradle:

代码语言:javascript
复制
defaultConfig {
    targetSdkVersion 20
}

否则(Eclipse等)使用AndroidManifest.xml:

代码语言:javascript
复制
<uses-sdk android:minSdkVersion="..." android:targetSdkVersion="20" />
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003951

复制
相关文章

相似问题

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