-1

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

1 Answers1

0

I think this post may halp you to implement your idea:

If you are planing to use it inside any function like onUpdate or onEnabled etc of Appwidgetprovider, then all those functions have context as a input parameter. You can use that context for using PackageManager as you are doing here.

Also in your question you mention flashlight. So just check if you need FEATURE_CAMERA_FLASH or FEATURE_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!");
 }

FROM: Check if a device has flashlight

Check also:

Hope it help

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94