0
以及我正在使用服務在上&關閃光燈的相機,它工作正常,但我的手機相機應用程序崩潰,我無法釋放相機服務如何在服務中打開和關閉閃光燈相機
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();
}
謝謝兄弟,它的工作原理。 – Uday
Enjoy.if是好的,那麼不要忘記接受和upvote :) –
好吧你不能投票,因爲低信譽,但你可以接受它 –