我使用 android 相机代码教程http://developer.android.com/guide/topics/media/camera.html#custom-camera创建了一个适用于 android 的相机应用程序。它适用于 XperiaZ - LgoptimusBlack- GalaxyNexus4 和其他一些设备。但是使用 Nexus-7 android 4.2.2 它给了我一个表面视图错误,它无法在表面上创建相机预览。我尝试了其他一些样品,但没有结果。这是日志猫:
FATAL EXCEPTION: main
java.lang.NullPointerException
at com.test.mycamera.CameraPreview.surfaceCreated(CameraPreview.java:33)
at android.view.SurfaceView.updateWindow(SurfaceView.java:569)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:174)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)