默認onMS
和offMS
見Android source的答案:
<!-- 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>
但是不同的ROM的可能有不同的值,這對於例如礦返回5000
爲config_defaultNotificationLedOff
所以你可能。要在運行時獲取它們:
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")));
據diff,這些屬性保證EXIS t在Android 2.2+(API等級8+)上。
對不起,但這是混淆。 U使用Notification notf = .. Builder。那不運行。我也無法調用build()。 (我用作最小的SDK 8)。所以我必須調用builder.getNotification();.但是這也不會運行... – StefMa 2013-02-27 11:08:36
@StefanM。我用我的示例項目中的實際代碼更新了我的答案。 'NotificationCompat.Builder.build'可以從API級別3獲得。 – 2013-02-27 11:21:02
只有更多的困惑... build()is'nt available說Eclipse!和setIcon太... – StefMa 2013-02-27 11:33:05