我想创建一个自定义通知.所以我想改变灯光和音调.
我使用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")));
根据diff,这些属性保证存在于Android 2.2(API级别8)上.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。