Im making a flash aplication for a school proyect but my phone doesn't have an flashlight so.. i have a idea to make the validation if my phone dont have a flashlight so light up the screen.
can someone help me ? :D
Im making a flash aplication for a school proyect but my phone doesn't have an flashlight so.. i have a idea to make the validation if my phone dont have a flashlight so light up the screen.
can someone help me ? :D
I think this post may halp you to implement your idea:
If you are planing to use it inside any function like
onUpdate
oronEnabled
etc ofAppwidgetprovider
, then all those functions havecontext
as a input parameter. You can use that context for usingPackageManager
as you are doing here.Also in your question you mention
flashlight
. So just check if you needFEATURE_CAMERA_FLASH
orFEATURE_CAMERA
.Context context = this; PackageManager packageManager = context.getPackageManager(); // if device support flash? if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { //yes Log.i("camera", "This device has flash supported!"); }else{ //no Log.i("camera", "This device has no flash support!"); }
Check also:
Hope it help