请别人帮我。我试图将http://drobosson.blogspot.com/2011/01/google-android-camera-preview-data.html和http://marakana.com/forums/android/examples/39.html转换为Monodroid(C#),但都没有成功。我遵循指示(据我所知),我不知道如何预览相机(我甚至没有拍摄PICTURE)。Monodroid相机+预览
这里是我当前的代码 - 它失败的Android.Hardware.Camera.Open()方法有了java.lang.RuntimeException(堆栈跟踪说“在Android.Runtime.JNIEnv.CallStaticObjectMethod(IntPtr的JCLASS,IntPtr的jmethod)[0x00000] in:0 at Android.Hardware.Camera.Open()...“)
我已经在清单中添加了相机权限。
代码:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.CameraPage);
_surfaceView = FindViewById<SurfaceView>(Resource.Id.imgCapture);
_debug = FindViewById<TextView>(Resource.Id.lblCameraDebug);
try
{
_camera = Android.Hardware.Camera.Open();
//Android.Hardware.Camera.Parameters camparam = _camera.GetParameters();
//camparam.SetPreviewSize(_surfaceView.Width, _surfaceView.Height);
//_camera.SetParameters(camparam);
//_camera.SetPreviewDisplay(_surfaceView.Holder);
//_camera.StartPreview();
}
catch(Exception ex)
{
_debug.Text = string.Format("Error: {0} - StackTrace: {1}", ex.Message,ex.StackTrace);
}
}