1
我想用led /手電筒給一些效果。但它並不快速閃爍,即使我嘗試了睡眠(2),但它需要時間眨眼。我想快點閃爍。Android如何快速閃爍led /手電筒
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();
}
代碼從我自己的項目在這裏: [NotifFlashlight ](http://sourceforge.net/p/notifflashlight/code/ci/master/tree/src/com/whd/notifflashlight/NotifFlashlightService.java#l132) – WHDeveloper 2013-10-21 19:13:47
感謝兄弟爲我工作:) – Sourabh 2014-02-15 07:36:49
這並沒有工作我的Nexus 5與棒棒糖。不過,它的確在索尼Z3上使用了KitKat。需要一個真正的PreviewDisplay – Gober 2014-12-22 09:53:23