我想创建一个自定义通知.所以我想改变灯光和音调.
我使用NotificationCompat.Builder.
我使用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")));