title: Access Android Camera.Parameters from Unity
body: <p>I would like to get the number of cameras from the android device, check if one is backfacing and for that camera get the horizontal and vertical view angles <code>Camera.Parameters.getHorizontalViewAngle()</code>.</p>
  
  <p>I would like to do this from a Unity3D c# script but my java skills are limited. Can anybody offer any help?
  I have this code:</p>
  
  <pre><code>using UnityEngine;
  
  #if UNITY_ANDROID
  public class CameraParametersAndroid
  {
      public static float HorizontalViewAngle { get; protected set; }
      public static float VerticalViewAngle   { get; protected set; }
      public static int   numCameras          { get; protected set; }
  
      static CameraParametersAndroid()
      {
          AndroidJavaClass unityPlayerClass = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"),
                           cameraClass = new AndroidJavaClass ("android.hardware.Camera"),
                           cameraParametersClass = new AndroidJavaClass ("android.hardware.Camera.Parameters"),
                           cameraInfoClass = new AndroidJavaClass ("android.hardware.Camera.CameraInfo");
  
          AndroidJavaObject currentActivity = unityPlayerClass.GetStatic&lt;AndroidJavaObject&gt;("currentActivity");
          object[] args = {currentActivity};
  
          AndroidJavaObject camera = cameraClass.CallStatic&lt;AndroidJavaObject&gt;("getCamera", args);
  
          if (camera != null)
          {
              AndroidJavaObject cameraParameters = camera.Call&lt;AndroidJavaObject&gt;("getParameters");
  
              numCameras = camera.Call&lt;int&gt;("getNumberOfCameras");
              HorizontalViewAngle = cameraParameters.Call&lt;float&gt;("getHorizontalViewAngle");
              VerticalViewAngle   = cameraParameters.Call&lt;float&gt;("getVerticalViewAngle");
  
          }
          else
          {
              Debug.LogError("[CameraParametersAndroid] Camera not available");
          }
      }
  }
  #endif
  </code></pre>
  
  <p>but not even the <code>getNumberOfCameras()</code> call works.</p>