大家好,我正在开发应用程序,因为我必须获取用户的信息,如姓名,地址等等。之后的信息得到我需要捕获用户的图像,我需要捕获图像,而无需用户任何intertaion(只是一个按钮单击必须启动前置摄像头并拍摄用户图像并保存到SD卡如SDCARD / MY文件夹NAME)我这样做Link
但它给我的错误就像
12-23 11:11:03.851: E/AndroidRuntime(14978): FATAL EXCEPTION: main
12-23 11:11:03.851: E/AndroidRuntime(14978): java.lang.RuntimeException: takePicture failed
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.hardware.Camera.native_takePicture(Native Method)
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.hardware.Camera.takePicture(Camera.java:1280)
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.hardware.Camera.takePicture(Camera.java:1225)
12-23 11:11:03.851: E/AndroidRuntime(14978): at com.example.test.TakePhoto$1.handleMessage(TakePhoto.java:90)
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.os.Looper.loop(Looper.java:137)
12-23 11:11:03.851: E/AndroidRuntime(14978): at android.app.ActivityThread.main(ActivityThread.java:5214)
12-23 11:11:03.851: E/AndroidRuntime(14978): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 11:11:03.851: E/AndroidRuntime(14978): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 11:11:03.851: E/AndroidRuntime(14978): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
12-23 11:11:03.851: E/AndroidRuntime(14978): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
12-23 11:11:03.851: E/AndroidRuntime(14978): at dalvik.system.NativeStart.main(Native Method)
已经给出了
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />
<uses-permission android:name="android.permission.CAMERA" />
我已经测试了这段代码这[代码]但它给了我这个错误
12-23 12:56:57.917: E/AndroidRuntime(6385): FATAL EXCEPTION: main
12-23 12:56:57.917: E/AndroidRuntime(6385): java.lang.NullPointerException
12-23 12:56:57.917: E/AndroidRuntime(6385): at com.example.testlogin.MakePhotoActivity$1.onClick(MakePhotoActivity.java:33)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.view.View.performClick(View.java:4421)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.view.View$PerformClick.run(View.java:17904)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.os.Handler.handleCallback(Handler.java:730)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.os.Handler.dispatchMessage(Handler.java:92)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.os.Looper.loop(Looper.java:137)
12-23 12:56:57.917: E/AndroidRuntime(6385): at android.app.ActivityThread.main(ActivityThread.java:5214)
12-23 12:56:57.917: E/AndroidRuntime(6385): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 12:56:57.917: E/AndroidRuntime(6385): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 12:56:57.917: E/AndroidRuntime(6385): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
12-23 12:56:57.917: E/AndroidRuntime(6385): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
12-23 12:56:57.917: E/AndroidRuntime(6385): at dalvik.system.NativeStart.main(Native Method)