Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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 – 通知setLights()默认值?全部内容,希望文章能够帮你解决android – 通知setLights()默认值?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。