我有一个显示自定义通知的应用.问题是,在Android 5中运行时,通知栏中的小图标显示为白色.我怎样才能解决这个问题?
我正在通过通知设计模式,并没有找到任何谈论通知图标背景.您可能已经注意到,自定义通知只有浅灰色背景.但是环聊等应用或简单的USB调试通知都会为其通知图标背景提供自定义颜色.
有没有可能将那种灰色变成其他东西?(以编程方式显示特定圆圈的颜色)

我是FCM的新手.我无法让FCM使用我的应用程序图标作为通知图标,图标始终为白色空白图标.
我向mipmap文件夹导入了一个图标但似乎没有任何改变.正如一些家伙所说,这是因为在这个问题中的棒棒糖通知
但问题是,FCM通知会自动弹出,我无法让Notification构建器覆盖图标.我该怎么改变它?
android android-notifications firebase firebase-cloud-messaging firebase-notifications
我正在尝试将Firebase Cloud Messaging集成到我的Android应用程序中.但是,当应用在后台或已关闭时,Firebase通知会显示灰色方块图标,而不是应用程序的启动器图标.
如何在不实施Firebase服务器API和发送数据消息的情况下将通知图标设为我的应用程序徽标?
我遇到了这个问题,我Bitmap从我在通知中使用的URL 生成了一个.然而,在我的手机上,Bitmap显示像一个小的白色方块.我调查了一下,发现很多帖子就像这样谈论它:图标没有显示在通知中:显示的是白色方块
我知道我Small Icon的通知确实是透明的.但是,对于Large Icon,我意识到它Large Icon不能透明,因为它实际上是Bitmap我从URL生成的.我怎样才能解决这个问题并确保图像正确呈现而不是将其Large Icon显示为白色方块?这是我的尝试:
NotificationService.java:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setContentTitle(getString(R.string.app_name))
.setContentText(remoteMessage.getNotification().getBody())
.setTicker(remoteMessage.getFrom() + " has responded!")
.setLargeIcon(AndroidUtils.getBitmapFromURL(remoteMessage.getNotification().getIcon()))
.setAutoCancel(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setStyle(new NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification().getBody()))
.setSmallIcon(R.drawable.ic_tabs_notification_transparent);
Run Code Online (Sandbox Code Playgroud)
AndroidUtils.java:
public static Bitmap getBitmapFromURL(String userId) {
try {
URL imgUrl = new URL("https://graph.facebook.com/" + userId + "/picture?type=large");
InputStream in = (InputStream) imgUrl.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(in);
Bitmap output;
Rect srcRect;
if (bitmap.getWidth() > bitmap.getHeight()) {
output = Bitmap.createBitmap(bitmap.getHeight(), …Run Code Online (Sandbox Code Playgroud) 我使用下面的代码片段在我的Android应用程序中生成通知.
private void sendNotification(String contentText, String message) {
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.putExtra("clear","clear");
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent piResult = PendingIntent.getActivity(this, 0, resultIntent,0);
NotificationCompat.Builder builder=new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setColor(ContextCompat.getColor(getApplicationContext(),R.color.red))
.setContentTitle("title")
.setContentText(message)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(getResources()
,R.drawable.notification))
.setContentIntent(piResult);
NotificationCompat.InboxStyle notification = new NotificationCompat.InboxStyle(builder);
int i;
for(i=0; i<messageList.size();i++){
notification.addLine(messageList.get(i));
}
notification.setBigContentTitle("title");
notification.setSummaryText(contentText);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID,notification.build());
}
Run Code Online (Sandbox Code Playgroud)
它适用于android 5和6但是对于android nougat它不起作用
所以我创建了背景透明且完全白色的图标并动态设置颜色。
但我只能设置一种颜色(setColor())。
所以我的问题是:-
Android通知图标如何支持多种颜色(两种以上颜色或颜色渐变)?注意:- 我参考了Android 推送通知:通知中未显示图标,而是显示白色方块
感谢您提前的支持。
android apple-push-notifications android-notification-bar material-design androiddesignsupport
我是新手,所以如果我的问题很简单,请不要杀我。
通知图标不是这样显示的
我把这条路
\android\app\src\main\res\drawable
这是我的图标代码:
final settingsAndroid = AndroidInitializationSettings('app_icon'); final settingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload)); final settingsIOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload)); notifications.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);
任何人都可以帮助我如何在通知中预览我的图标?