我正在尝试为我的应用程序设置一个新的通知图标,但似乎无法使其正常工作。我可以接收到通知,但在状态栏中看到的是一个黑色/灰色圆圈,如下所示:
我的MessageService代码如下:
public class MyMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, MessageActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("notification_msg_id", remoteMessage.getData().get("my_msg_id"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder
= new NotificationCompat.Builder(this)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_stat_my_logo)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setColor(getResources().getColor(R.color.colorBlack))
.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
我使用了这个非常好用的工具生成了小图标,而且你可以看到Android Studio能够在需要的每个尺寸中找到图片:
以下是我的SDK版本:
我之前读到过可能会出现一些关于drawable缓存的问题,所以我已经试过无效化所有缓存并清理/重建项目。我也试过不同的图片文件和XML矢量可绘制对象。
你们有什么想法,我做错了什么或者如何进一步排除问题呢?
提前致谢!
编辑:
这是我正在尝试使用的xxxhdpi-v11格式的图标(它是白色的,你可能需要点击它才能看到):