I want to create a strobe effect,make the flashlight blink.Below is my code,right now what i have achieve is to make it flash but only once,that's why i need to help me make it flash for a great deal of time.
public class Strobe extends Activity {
Camera cam;
private static final String TAG = null;
private Handler mHander = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
strobe();
}
private void turnOnLight(){
for(int x = 0; x == 10; x++);{ //although for does exist does nothing and that is in all for i have put around my program,don't know why
Log.d("tagname","runs 10 times a");
cam = Camera.open();
Parameters params = cam.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(params);
cam.startPreview();
cam.autoFocus(new AutoFocusCallback(){
public void onAutoFocus(boolean success, Camera camera) {
}
});
}
}
private void turnOffLight(){
for(int x = 0; x == 10; x++);{
cam.stopPreview();
cam.release();
Log.d("tagname","runs 10 times b");
}
}
private void strobe(){
for(int x = 0; x == 10; x++);{
Thread timer = new Thread(){
public void run(){
turnOnLight();
try{
Thread.sleep(300);
}catch(InterruptedException e){
e.printStackTrace();
}
turnOffLight();
Log.d("tagname","runs 10 times c");
};
};timer.start();
};
}
};