【发布时间】:2015-02-23 14:47:33
【问题描述】:
我已经为我的通知实现了红色 LED 灯以用于测试目的,但是...
我是否必须检查设备是否有 LED(以防设备没有此功能),如果有,该怎么做?另外,LED 的颜色是预先确定的吗?
我试图找到一些文档或线程可以为我提供这些问题的答案,但没有运气......
【问题讨论】:
标签: android android-notifications led
我已经为我的通知实现了红色 LED 灯以用于测试目的,但是...
我是否必须检查设备是否有 LED(以防设备没有此功能),如果有,该怎么做?另外,LED 的颜色是预先确定的吗?
我试图找到一些文档或线程可以为我提供这些问题的答案,但没有运气......
【问题讨论】:
标签: android android-notifications led
您不必检查 LED 的可用性。即使没有 LED,代码也不会崩溃。您可以将任何颜色设置为十六进制颜色代码。
Notification notification = new Notification();
notification .ledARGB = 0xFFff0000;
notification .flags = Notification.FLAG_SHOW_LIGHTS;
【讨论】:
没有办法做到这一点。
根据Can I detect the presence/absence of 'LED notification' on an Android device?
大多数硬件功能都通过包管理器公开:
PackageManager pm = getActivity ().getPackageManager ();
boolean hasBluetooth = pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
但不是这个。
还有一个功能请求记录在案: https://code.google.com/p/android/issues/detail?id=38481
【讨论】: