if(camera == null){
Toast.makeText(getBaseContext(),"without camera",Toast.LENGTH_LONG).show();
return;
}
- - - - - - - - - - - - - - - - - - - - -
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (isLightOn) {
p.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(p);
camera.stopPreview();
isLightOn = false;
Toast.makeText(context, R.string.off, Toast.LENGTH_SHORT).show();
} else {
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(p);
camera.startPreview();
isLightOn = true;
Toast.makeText(context, R.string.on, Toast.LENGTH_SHORT).show();
}
}
});
对不起,我的Eng。
How do I make that when you click on the button to check for flash the phone? And when no flash - display a message (Toast)