I want to create a custom notification. So i want to change the lights and the tone.
I use the NotificationCompat.Builder
for that.
Now i want to change the Lights via setLights()
;
Works fine. But i want set the default value of the onMS
and offMS
. I haven't find something about that.
Can anybody help me to find the default values? Here is the documentation for that: http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setLights(int, int, int)
ChannelId is a unique String to identify each NotificationChannel and is used in Notification.
Set the small icon resource, which will be used to represent the notification in the status bar. Set the small icon, which will be used to represent the notification in the status bar and content view (unless overridden there by a large icon ).
To associate the PendingIntent with a gesture, call the appropriate method of NotificationCompat. Builder. For example, if you want to start Activity when the user clicks the notification text in the notification drawer, you add the PendingIntent by calling setContentIntent().
See the Android source for answer:
<!-- Default color for notification LED. -->
<color name="config_defaultNotificationColor">#ffffffff</color>
<!-- Default LED on time for notification LED in milliseconds. -->
<integer name="config_defaultNotificationLedOn">500</integer>
<!-- Default LED off time for notification LED in milliseconds. -->
<integer name="config_defaultNotificationLedOff">2000</integer>
However different ROMs might have different values for these. For example mine returns 5000
for config_defaultNotificationLedOff
. So you might want to fetch them at runtime:
Resources resources = context.getResources(),
systemResources = Resources.getSystem();
notificationBuilder.setLights(
ContextCompat.getColor(context, systemResources
.getIdentifier("config_defaultNotificationColor", "color", "android")),
resources.getInteger(systemResources
.getIdentifier("config_defaultNotificationLedOn", "integer", "android")),
resources.getInteger(systemResources
.getIdentifier("config_defaultNotificationLedOff", "integer", "android")));
According to diff, these attributes are guaranteed to exist on Android 2.2+ (API level 8+).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With