-1

I have a project on Android where I get some notifications. My question is, how can I change the color of the notification? I already have a title and some text. Any ideas?

void setNotification() {
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.cancel(uniqueID);
    Context context = getApplicationContext();
    int icon = R.drawable.notif;// R.drawable.notification_icon;
    CharSequence tickerText = "New Violations";
    long when = System.currentTimeMillis();

    CharSequence contentTitle = "New violations";
    CharSequence contentText = "Click to view the violations !";

    Notification notification = new Notification(icon, tickerText, when);
    Intent notificationIntent = new Intent(this, NotficationClass.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.flags = Notification.FLAG_AUTO_CANCEL;
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
    mNotificationManager.notify(uniqueID, notification);

}

notification

Don't Panic
  • 41,125
  • 10
  • 61
  • 80
Petrica
  • 37
  • 2
  • 10
  • you can try this new Notification.Builder(context).setLights(Color.YELLOW, 500, 500) – Developer Sep 12 '13 at 11:59
  • setLights sets the color of the RGB LED in (some) android devices, but has nothing to do with the background color (black in the picture in the question) – Gavriel Feb 25 '15 at 09:45

1 Answers1

-1

Use this hope this will resolve your problem

Notification.Builder notification = new Notification.Builder(context)
                .setLights(Color.Res, 500, 500)
                ;
                notification.defaults = 0;
Developer
  • 6,292
  • 19
  • 55
  • 115
  • I know that Notification is deprecated but ,i you have the good idea to use Notification.Builder , but can i do this somehow with my Notification class? – Petrica Sep 12 '13 at 12:08
  • i have used this so i told you after that i don't know about Notification class sorry – Developer Sep 12 '13 at 12:10
  • So... i have to set up my notification again ? – Petrica Sep 12 '13 at 12:17
  • see this link will help you http://stackoverflow.com/questions/14953793/android-notification-led-doesnt-use-my-color – Developer Sep 12 '13 at 12:39
  • setLights sets the color of the RGB LED in (some) android devices, but has nothing to do with the background color (black in the picture in the question) – Gavriel Feb 25 '15 at 09:46