How to turn on front flash light programmatically in Android

0 votes
I want to programmatically trigger the front flash on Android (not with the camera preview). I looked it up on Google, but the advice I received directed me to this page.

Does anyone have links or an example of the code?
Nov 4 in Android by Edureka
• 12,290 points
30 views

1 answer to this question.

0 votes

For this problem you should:

  1. Check whether the flashlight is available or not.

  2. If so then Turn Off/On

  3. If not then you can do whatever, according to your app needs.

To determine whether the device has flash:

You can use the following:

 context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

This will return true in the presence of a flash and false otherwise.

answered Nov 8 by Edureka
• 10,880 points

Related Questions In Android

0 votes
0 answers

How to get the device's IMEI/ESN programmatically in android?

I want to use the IMEI to ...READ MORE

Nov 16 in Android by Edureka
• 10,880 points
17 views
0 votes
0 answers

How to make grid view scroll horizontally not vertically in android?

I use a flexible Grid View. means ...READ MORE

Sep 21 in Android by Edureka
• 12,290 points
38 views
0 votes
1 answer
0 votes
1 answer

How to set my Activity as main activity in android?

The "intent-filter" in "AndroidManifest.xml" allows you to ...READ MORE

answered Nov 8 in Android by Edureka
• 12,290 points
32 views
0 votes
1 answer

Android open camera from button

you can use the below syntax as ...READ MORE

answered Jun 14 in Others by polo
• 1,480 points
96 views
0 votes
0 answers

Use camera flashlight in Android

I'm trying to use the cameras LED ...READ MORE

3 days ago in Android by Ashwini
• 2,760 points
11 views
0 votes
1 answer

Running docker on Android

According to the documentation, the Android kernel is ...READ MORE

answered Aug 1, 2018 in Docker by Kalgi
• 52,350 points
3,022 views
0 votes
1 answer

Task Canceled Exception while invoking AWS Lambda

I'm guessing either the TaskCanceledException instance is ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,100 points
1,656 views
0 votes
1 answer

How to display Toast in Android?

Use the show() function of the Toast ...READ MORE

answered Nov 8 in Android by Edureka
• 10,880 points
36 views
0 votes
1 answer

Android in-app billing - How to handle refunds ?

Simply disregard the library's purchase to overcome ...READ MORE

answered Nov 10 in Android by Edureka
• 10,880 points
44 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP