mirror of
https://github.com/FossifyOrg/Camera.git
synced 2026-06-13 18:49:51 -04:00
implement Flash
This commit is contained in:
@@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.hardware.Camera;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
public static Camera.CameraInfo getCameraInfo(int cameraId) {
|
||||
final Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
|
||||
@@ -14,4 +16,24 @@ public class Utils {
|
||||
public static void showToast(Context context, int resId) {
|
||||
Toast.makeText(context, context.getResources().getString(resId), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static boolean hasFlash(Camera camera) {
|
||||
if (camera == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Camera.Parameters parameters = camera.getParameters();
|
||||
|
||||
if (parameters.getFlashMode() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<String> supportedFlashModes = parameters.getSupportedFlashModes();
|
||||
if (supportedFlashModes == null || supportedFlashModes.isEmpty() ||
|
||||
supportedFlashModes.size() == 1 && supportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user