I'm building a flashlight app and I've learned that when I call
this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
,
the Nexus 7 returns true and when asking for the FlashModes()
the size is 1 and the option is called "off." So when I check whether or not flash exists on devices, if the device lies about it, I can run into trouble. I've added !android.os.Build.MODEL.equals("Nexus 7")
to my if statement to prevent crashing my app while testing on my Nexus 7.
If there are other devices that lie about having a flash, my app will likely crash on them. How can I avoid this?
you can implement a double check
after calling
check if
if no
check if