2013-09-12 4 views
-1

У меня есть проект на Android, где я получаю уведомления. Мой вопрос: как я могу изменить цвет уведомления? У меня уже есть заголовок и текст. Есть идеи?Android Notification цвет фона

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

+0

вы можете попробовать этот новый Notification.Builder (контекст) .setLights (Color.YELLOW, 500, 500) – Developer

+0

setLights устанавливает цвет RGB-светодиода в некоторых (некоторых) устройствах Android, но не имеет никакого отношения к цвету фона (черный в изображении в вопросе) – Gavriel

ответ

-1

Используйте эту надеюсь, что это будет решить вашу проблему

Notification.Builder notification = new Notification.Builder(context) 
       .setLights(Color.Res, 500, 500) 
       ; 
       notification.defaults = 0; 
+0

Я знаю, что уведомление устарело, но у вас есть хорошая идея использовать уведомление .Builder, но могу ли я сделать это как-то с моим классом уведомлений? – Petrica

+0

Я использовал это, поэтому я сказал вам после этого, что не знаю о классе уведомления, извините – Developer

+0

Итак ... мне нужно снова настроить свое уведомление? – Petrica

Смежные вопросы