Android通知背景颜色

时间:2013-09-12 11:33:54

标签: android notifications

我在Android上有一个项目,我收到了一些通知。我的问题是,如何更改通知的颜色?我已经有了一个标题和一些文字。有什么想法吗?

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

1 个答案:

答案 0 :(得分:-1)

使用此希望这将解决您的问题

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