Flashlight (Torch) is opening but not closing
问题 Following is the code which I used for opening Torch and closing it. But when I close it, it crashes. LogCat says " Runtime Exception : Fail to connect to camera service "! + hasFlash is not getting any value and is throwing Nullpointer exception. (I'm using it to check if the flash is present or not.) What am I doing Wrong? boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); if(hasFlash==true) { if(s.equalsIgnoreCase("FlashLight On") || s