[英]samsung galaxy ace surfaceview/ camera error
I am writting an app that is supposed to be compatible with the samsung galaxy ace. 我正在写一个应该与三星银河王牌兼容的应用程序。 I have the following code:
我有以下代码:
mPreview = (SurfaceView)findViewById(R.id.preview);
mPreview.getHolder().addCallback(this);
mPreview.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(0);
mCamera = Camera.open();
It crashes at 崩溃于
mCamera.setDisplayOrientation(0);
And gives the following error: 并给出以下错误:
/AndroidRuntime(18011): Caused by: java.lang.NullPointerException
I have tried to set the value to 90, 180, 270 and 360, but nothing seems to solve this issue. 我尝试将值设置为90、180、270和360,但是似乎没有任何方法可以解决此问题。
It is because mCamera is null. 这是因为mCamera为空。
You should call setDisplayOrientation()
after Camera.open()
. 您应该在
Camera.open()
之后调用setDisplayOrientation()
Camera.open()
。
It is written in Android developer site ( http://developer.android.com/reference/android/hardware/Camera.html ). 它是在Android开发者网站( http://developer.android.com/reference/android/hardware/Camera.html )中编写的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.