检查设备上是否存在通知LED以及可用的颜色

Mun*_* NS 5 android led android-notifications

为了测试目的,我已将红色LED灯用于通知,但是...

我是否需要检查设备是否具有LED(如果该设备不具有此功能),以及如何做到这一点?另外,LED颜色是否已预先确定?

我试图找到一些文档或主题来给我这些问题的答案,但是没有运气...

Asa*_*hna 1

您不必检查 LED 的可用性。即使没有 LED,代码也不会崩溃。您可以将任何颜色设置为十六进制颜色代码。

Notification notification = new Notification();
notification .ledARGB = 0xFFff0000;
notification .flags = Notification.FLAG_SHOW_LIGHTS;
Run Code Online (Sandbox Code Playgroud)