Check if a notification light exists on the device and what colors are available

I implemented a red LED for my notifications for testing, but ...

Do I need to check if the device has an LED (if the device does not have this function), and if so, how to do it? Also, are the LED colors preset?

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

+3


source to share


2 answers


There is no way to do this.

According to Can I detect presence / absence of "LED notification" on Android device?

Most of the hardware features are exposed through the package manager:



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

      

But not this one.

There is also a feature request to write: https://code.google.com/p/android/issues/detail?id=38481

+3


source


You don't need to check for an LED. the code will not fly out even if the LED is missing. you can set any color as hex color code.



Notification notification = new Notification();
notification .ledARGB = 0xFFff0000;
notification .flags = Notification.FLAG_SHOW_LIGHTS;

      

+1


source







All Articles