为了账号安全,请及时绑定邮箱和手机立即绑定

Android推送通知:图标未显示在通知中,而是显示白色方块

Android推送通知:图标未显示在通知中,而是显示白色方块

梵蒂冈之花 2019-08-02 16:34:52
Android推送通知:图标未显示在通知中,而是显示白色方块我的应用会生成通知,但我没有显示为该通知设置的图标。相反,我得到一个白色方块。我已经尝试调整图标的大小(尺寸720x720,66x66,44x44,22x22)。奇怪的是,当使用较小尺寸时,白色方块较小。我已经google了这个问题,以及生成通知的正确方法,从我读过的代码应该是正确的。可悲的是,事情并不像他们应该的那样。我的手机是带有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);}
查看完整描述

3 回答

?
慕雪6442864

TA贡献1812条经验 获得超5个赞

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

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


查看完整回答
反对 回复 2019-08-02
  • 3 回答
  • 0 关注
  • 3372 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信