請別人幫我。我試圖將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);
}
}