好吧,我正在使用服务来打开和关闭相机的闪光灯,它工作正常,但我的移动相机应用程序崩溃了,我无法释放相机服务
Camera camera = Camera.open();
final Parameters p = camera.getParameters();
if (isFlashOn)
{
Log.i("info", "torch is turned off!");
Toast toast= Toast.makeText(getApplicationContext(),
"Torch is turned off!",Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 100);
toast.show();
p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);
//Set flag to false
isFlashOn = false;
release=true;
}
//If Flag is set to false
else
{
Log.i("info", "torch is turned on!");
Toast toast= Toast.makeText(getApplicationContext(),
"Torch is turned on!",Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 100);
toast.show();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);
isFlashOn = true;
release=false;
}
if (release == true)
{
camera.stopPreview();
camera.release();
}