Android相机Flash预览

时间:2014-01-24 03:04:22

标签: android flash camera task preview

我的问题是下面的一个,我想要拍一张照片,但是我需要先打开相机,然后拍照然后关闭。

CameraPreview.flashTurnOff()是 void ,新的Timer()。计划参数是 task,int

如何将无效 CameraPreview.flashTurnOff()转换为任务?谢谢!

captureButton.setOnClickListener(new View.OnClickListener() //TAKE THE PICTURE
    {        
        @Override        
        public void onClick(View v) 
        {            
            if(isFlashOn == 1)
            {
                CameraPreview.flashTurnOn();
                new Timer().schedule(CameraPreview.flashTurnOff(), 1000);
                mCamera.takePicture(null, null, mPicture);
            }
            else
            {    
                mCamera.takePicture(null, null, mPicture);  
                Log.d(TAG, "Tirou foto");
            }
        }    
    });
}

1 个答案:

答案 0 :(得分:-1)

**That was the solution.**

class DesligaFlash extends Thread 
    {
        public void run()
        {
            try 
            {
                super.sleep(1000);
            } 
            catch (InterruptedException e) 
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            CameraPreview.flashTurnOff();
        }
    }

captureButton.setOnClickListener(new View.OnClickListener() //TAKE THE PICTURE
    {        
        @Override        
        public void onClick(View v) 
        {            
            if(isFlashOn == 1)
            {
                CameraPreview.flashTurnOn();
                DesligaFlash bagulho = new DesligaFlash();
                bagulho.run();
            }
            mCamera.takePicture(null, null, mPicture); 
        }   
    });