Created
May 28, 2014 10:26
-
-
Save beeradmoore/bf43c95e81686e36c7a1 to your computer and use it in GitHub Desktop.
General use function to detect flash with Xamarin.Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool HasFlash() | |
{ | |
if (_camera == null) | |
{ | |
return false; | |
} | |
bool hasFlash = MyMainActivity.PackageManager.HasSystemFeature(Android.Content.PM.PackageManager.FeatureCameraFlash); | |
if (hasFlash) | |
return true; | |
Camera.Parameters parameters = _camera.GetParameters(); | |
if (parameters.FlashMode == null) | |
{ | |
return false; | |
} | |
List<string> supportedFlashModes = parameters.SupportedFlashModes.ToList<string>(); | |
if (supportedFlashModes == null || supportedFlashModes.Count == 0 || (supportedFlashModes.Count == 1 && supportedFlashModes[0].Equals(Camera.Parameters.FlashModeOff))) | |
{ | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment