5

I've implemented red LED light for my notifications for test purposes, but...

Do I have to check if the device has LED (in case that device doesn't have this feature) and if so how to do it? Also, are LED colors predetermined?

I tried to find some docs or thread that would give me an answer for these questions but had no luck...

Cory Roy
  • 5,379
  • 2
  • 28
  • 47
Munez NS
  • 1,011
  • 1
  • 12
  • 31
  • Does this answer your question? [Can I detect the presence/absence of 'LED notification' on an Android device?](https://stackoverflow.com/questions/5997692/can-i-detect-the-presence-absence-of-led-notification-on-an-android-device) – Herohtar Feb 20 '23 at 14:34

2 Answers2

3

There is no way of doing this.

According to Can I detect the presence/absence of 'LED notification' on an Android device?

Most hardware features are exposed via the package manager:

PackageManager pm = getActivity ().getPackageManager ();
boolean hasBluetooth =  pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);

But not this one.

There is a feature request on record as well: https://code.google.com/p/android/issues/detail?id=38481

Community
  • 1
  • 1
Cory Roy
  • 5,379
  • 2
  • 28
  • 47
1

You don't have to check the availability of the LED. the code won't crash even if there is no LED. you can set any color as a hexadecimal color code.

Notification notification = new Notification();
notification .ledARGB = 0xFFff0000;
notification .flags = Notification.FLAG_SHOW_LIGHTS;
Asanka Senavirathna
  • 4,570
  • 4
  • 18
  • 20