How to make android phone flashlight blink

0 votes

I am making he LED flashlight of android phone blink based on binary: if char = 1 turn LED light on else if char = 0 turn LED off.

if ( char == '1'){ params.setFlashMode(Parameters.FLASH_MODE_ON); }              
if ( char == '0'){ params.setFlashMode(Parameters.FLASH_MODE_OFF);}

So I get the char from a String str ="101010101" the char gets the values 1, 0, 1 and so on, which is supposed to make the flashlight blink, however it blinks ones and that's it. How should I fix this problem?

Jun 2, 2022 in Others by polo
• 1,480 points
1,453 views

1 answer to this question.

0 votes

This might be too fast to blink:-

String[] list1 = { "1", "0", "1", "0", "1", "0", "1", "0", "1", "0" };
        for (int i = 0; i < list1.length; i++) {
            if (list1[i].equals("0")) {
                params.setFlashMode(Parameters.FLASH_MODE_ON);
            } else {
                params.setFlashMode(Parameters.FLASH_MODE_OFF);
            }
answered Jun 6, 2022 by nisha
• 2,210 points

Related Questions In Others

0 votes
0 answers

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

I have a dynamic Grid View. If ...READ MORE

May 21, 2022 in Others by Kichu
• 19,050 points
627 views
+1 vote
1 answer

How To Create Phone Number Format XXX-XXX-XXXX In Android

 can try: private String formatNumbersAsCode(CharSequence s) { ...READ MORE

answered Jun 14, 2022 in Others by polo
• 1,480 points
8,249 views
0 votes
1 answer

How to make rounded TextField in flutter?

Hi@akhtar, You can use decoration inside your TextField. This has ...READ MORE

answered Sep 10, 2020 in Others by MD
• 95,440 points
3,666 views
0 votes
1 answer

SEO - How to Show Phone Numbers in Google Search

<div itemscope itemtype="http://schema.org/LocalBusiness">         <span itemprop="telephone"><a href="tel:01234555666">Link Text Here</a></span>     </div> use ...READ MORE

answered Feb 14, 2022 in Others by narikkadan
• 63,420 points
250 views
0 votes
1 answer

How to open the Google Play Store directly from my Android application?

By using developer.andriod.com, one can solve this ...READ MORE

answered Feb 8, 2022 in Others by Rahul
• 9,670 points
524 views
0 votes
1 answer

How to open YouTube video link in android app?

The below code will do that: Intent intent ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,800 views
0 votes
1 answer

Launching Google Maps Directions via an intent on Android

We can open Google Maps app using ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,017 views
0 votes
1 answer

Android YouTube app Play Video Intent

The best way to run videos on ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
1,065 views
0 votes
1 answer

How to make a countdown timer in Android?

package com.example.countdowntimer; import java.util.concurrent.TimeUnit; import android.app.Activity; import android.os.Bundle; import android.os.CountDownTimer; import android.widget.TextView; public ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,858 views
0 votes
1 answer

How to make Diamond shape xml background for android view

you can do this: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,714 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