我从服务器下载图像作为位图并将其转换为drawable现在我想使用这个drawable作为通知图标.但我无法做到这一点.这是我的代码:
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(intent)
.setSmallIcon(bitmap)
.setWhen(when)
.build();
Run Code Online (Sandbox Code Playgroud)
但是icon是一个Resources int值,所以当我使用它时会出错.任何帮助
编辑:
现在我更新我的代码,现在我这样做:
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(intent)
.setSmallIcon(icon)
.setLargeIcon(bitmap)
.setWhen(when)
.build();
Run Code Online (Sandbox Code Playgroud)
但它左侧有大图标,右侧有小图标.我不希望这样,为此我删除setSmallIcon行并运行我的代码,但它没有显示通知