我正在尝试使用 LED/手电筒显示一些效果,但它没有快速闪烁。我什至试过sleep(2)
,但眨眼需要时间。我希望它闪烁得更快。
public void flash_effect() throws InterruptedException
{
cam = Camera.open();
final Parameters p = cam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
Thread a = new Thread()
{
public void run()
{
for(int i =0; i < 10; i++)
{
cam.setParameters(p);
cam.startPreview();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cam.stopPreview();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
a.start();
}