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 in Others by polo
• 1,500 points
38 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 by nisha
• 2,180 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 in Others by Kichu
• 19,040 points
67 views
0 votes
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 in Others by polo
• 1,500 points
139 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,360 points
1,975 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 in Others by narikkadan
• 11,280 points
36 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 in Others by Rahul
• 9,000 points
23 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 in Others by nisha
• 2,180 points
76 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 in Others by nisha
• 2,180 points
66 views
0 votes
1 answer

Android YouTube app Play Video Intent

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

answered Jun 6 in Others by nisha
• 2,180 points
63 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 in Others by nisha
• 2,180 points
67 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 in Others by nisha
• 2,180 points
145 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP