Android 通知setLights()的默认值?

Android 通知setLights()的默认值?,android,notifications,android-notifications,Android,Notifications,Android Notifications,我想创建一个自定义通知。所以我想改变灯光和音调。 为此,我使用了通知compat.Builder 现在我想通过setLights()更改灯光; 很好。但是我想设置onMS和offMS的默认值。我还没找到这方面的东西 有人能帮我找到默认值吗? 以下是相关文档:您应该能够使用以下工具执行此操作: Notifictaion notf = new Notification.Builder(this).setXXX(...).....build(); notf.ledARGB = <your col

我想创建一个自定义通知。所以我想改变灯光和音调。 为此,我使用了
通知compat.Builder

现在我想通过
setLights()
更改灯光; 很好。但是我想设置
onMS
offMS
的默认值。我还没找到这方面的东西

有人能帮我找到默认值吗?
以下是相关文档:

您应该能够使用以下工具执行此操作:

Notifictaion notf = new Notification.Builder(this).setXXX(...).....build();
notf.ledARGB = <your color>;
notf.ledOnMS = <your value>;  //or skip this line to use default
notf.ledOffMS = <your value>; //or skip this line to use default
@阿列克斯G 那没用。我有来自利比亚同胞的最新消息。但是Eclipse说
build()
不可用。 我不知道为什么。医生说是的你

这是我当前的代码:

    NotificationCompat.Builder notify = new NotificationCompat.Builder(context);
    notify.setLights(Color.parseColor(led), 5000, 5000);
    notify.setAutoCancel(true);
    notify.setSound(Uri.parse(tone));
    notify.setSmallIcon(R.drawable.ic_stat_kw);
    notify.setContentTitle("Ttiel");
    notify.setContentText("Text");
    Intent showIntent = new Intent(context, Activity_Login.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, showIntent, 0); 
    notify.setContentIntent(contentIntent);

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notify.getNotification());
运行良好。但不使用
setLights()
中的默认
onMS
offMS
:(

有关答案,请参阅:

<!-- 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>

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

抱歉,这有点混淆。您使用Notification notf=…Builder。这不会运行。此外,我不能调用build()(我使用最小的SDK 8)。因此我必须调用Builder.getNotification();。但这也不会运行…@StefanM。我用示例项目中的实际代码更新了我的答案。
NotificationCompat.Builder.build
可从API级别3获得。只有更混乱的…build()“不可用”表示Eclipse!设置图标也是…@StefanM。抱歉,它应该是
setmallicon
setLargeIcon
build
可用-我的Eclipse很高兴将其用于API级别7。也许你应该更新你的兼容性库。build()被添加为getNotification()的同义词在API 16中,但它们做同样的事情。
<!-- 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>
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")));