问题
I'm trying to use a Notification that also uses the Notification LED on my S3, but for some reason the color will always be blue (I guess it's the default?). I tried to use different colors but nothing changes. Other apps (like Whatsapp, Gmail and Facebook have no problems with showing a different color light).
Notification.Builder noteBuilder = new Notification.Builder(context)
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_DEFAULT)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(ContentTitle)
.setContentText(ContentText)
.setLights(Color.YELLOW, 500, 500)
;
Intent noteIntent = new Intent(context,HoofdScherm.class);
PendingIntent notePendingIntent = PendingIntent.getActivity(context, 0, noteIntent, PendingIntent.FLAG_CANCEL_CURRENT);
noteBuilder.setContentIntent(notePendingIntent);
Notification note = noteBuilder.build();
note.ledARGB = Color.YELLOW;
NotificationManager mgr = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
mgr.notify(0,note);
回答1:
You need to make sure all the defaults are overridden by setting
notification.defaults = 0;
回答2:
Have a look on source below. Working perfectly on S3:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(ctx)
.setPriority(Notification.PRIORITY_HIGH)
.setSmallIcon(getNotificationIcon())
.setColor(0xff493C7C)
.setContentTitle(ctx.getString(R.string.app_name))
.setContentText(msg)
.setDefaults(Notification.DEFAULT_SOUND)
.setLights(0xff493C7C, 1000, 1000)
.setStyle(new NotificationCompat.BigTextStyle().bigText(styledMsg));
来源:https://stackoverflow.com/questions/14953793/android-notification-led-doesnt-use-my-color