Xem Android source cho câu trả lời:.
<!-- 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 Tuy nhiên khác nhau có thể có giá trị khác nhau cho các Ví dụ tôi trả 5000
cho config_defaultNotificationLedOff
Vì vậy, bạn có thể. muốn tìm nạp chúng khi chạy:
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")));
Theo diff, các thuộc tính này được đảm bảo cho exis t trên Android 2.2+ (API cấp 8+).
Xin lỗi nhưng điều này bị nhầm lẫn. U sử dụng Thông báo notf = .. Builder. Điều đó không chạy. Ngoài ra tôi không thể gọi build(). (Tôi sử dụng SDK 8 nhỏ nhất). Vì vậy, tôi phải gọi builder.getNotification() ;. Nhưng điều này cũng không chạy ... – StefMa
@StefanM. Tôi đã cập nhật câu trả lời của mình bằng mã thực tế từ dự án mẫu của mình. 'NotificationCompat.Builder.build' có sẵn từ cấp API 3. –
Chỉ còn lộn xộn hơn ... build() is'nt available Eclipse! Và setIcon cũng vậy ... – StefMa