我的应用程序生成一个通知,但我为该通知设置的图标没有显示。相反,我得到一个白色的正方形。
我试过调整图标的png大小(维度为720x720、66x66、44x44、22x22)。奇怪的是,当使用较小的尺寸时,白色方块就更小了。
我搜索了这个问题,以及生成通知的正确方法,从我所读到的内容来看,我的代码应该是正确的。可悲的是,事情并不像他们应该做的那样。
我的手机是带有Android5.1.1的Nexus 5。这个问题也出现在仿真器上,三星Galaxy 5.0.1的s4和Android5.0.1的摩托罗拉Moto (都是我借来的,现在还没有)。
通知代码如下,以及两个屏幕截图。如果您需要更多的信息,请随时索取。
谢谢你们所有人。
@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);
}


发布于 2015-06-12 04:55:47
根据谷歌的设计指南
通知图标必须是完全白色的。
https://stackoverflow.com/questions/30795431
复制相似问题