我正在尝试在我的FCM接收器中从我的服务器收到有效负载时建立自己的通知,我将通知图标设置为我的应用程序图标,该图标是PNG格式,但是,我的通知显示为相反的白色方块,我不知道为什么.. 这是我的代码:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle("Your chat is going to expire tomorrow!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, main_activity.class);
resultIntent.putExtra("launchedFromNotification",true);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your app to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(main_activity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mNotificationId is a unique integer your app uses to identify the
mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build());
答案 0 :(得分:0)
当您使用非alpha图标
时,通常会发生这种情况当您在通知上使用图标时,Android会绘制图标的所有非alpha(非透明)部分。这意味着如果您使用方形图像作为通知图标,它就会显示为白色方块。
要解决此问题,只需使用类似形状的图标即可。请查看以下内容以供参考:
Hibernate Tips: How to map native query results to entities tutorial