android – 通知setLights()默认值?

我想创建一个自定义通知.所以我想改变灯光和音调.
我使用NotificationCompat.Builder.

现在我想通过setLights()更改Lights;
工作良好.但我想设置onMS和offMS的默认值.我还没有找到相关的东西.

任何人都可以帮我找到默认值吗?
以下是该文档:http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setLights(int,int,int)

解决方法

请参阅 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可能具有不同的值.例如,我的config_defaultNotificationLedOff返回5000.所以你可能想在运行时获取它们:

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",resources.getInteger(systemResources
        .getIdentifier("config_defaultNotificationLedOff","android")));

根据diff,这些属性保证存在于Android 2.2(API级别8)上.

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...