我想创建自己的相机应用程序。当我点击按钮时,它会拍摄照片并将其保存在小册子中。我想要的是在没有预览的情况下拍摄照片而不点击任何按钮。
我正在搜索很多,但我没有得到正确解决我创建的一个代码。但是当我运行它时它是错误的。请给我精确的解决方案。你可以给我自己的项目,自动捕捉照片并自动保存图库。
enter link MainActivity.java here
错误:
07-11 09:51:31.885: E/AndroidRuntime(2666): FATAL EXCEPTION: main
07-11 09:51:31.885: E/AndroidRuntime(2666): java.lang.RuntimeException: Unable to resume activity {com.example.capturephotoautometic_one/com.example.capturephotoautometic_one.SimpleCameraIntentFragment}: java.lang.RuntimeException: Fail to connect to camera service
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2742)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.os.Looper.loop(Looper.java:137)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-11 09:51:31.885: E/AndroidRuntime(2666): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 09:51:31.885: E/AndroidRuntime(2666): at java.lang.reflect.Method.invoke(Method.java:511)
07-11 09:51:31.885: E/AndroidRuntime(2666): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-11 09:51:31.885: E/AndroidRuntime(2666): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-11 09:51:31.885: E/AndroidRuntime(2666): at dalvik.system.NativeStart.main(Native Method)
07-11 09:51:31.885: E/AndroidRuntime(2666): Caused by: java.lang.RuntimeException: Fail to connect to camera service
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.hardware.Camera.native_setup(Native Method)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.hardware.Camera.<init>(Camera.java:340)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.hardware.Camera.open(Camera.java:317)
07-11 09:51:31.885: E/AndroidRuntime(2666): at com.example.capturephotoautometic_one.SimpleCameraIntentFragment.onResume(SimpleCameraIntentFragment.java:46)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.Activity.performResume(Activity.java:5182)
07-11 09:51:31.885: E/AndroidRuntime(2666): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
07-11 09:51:31.885: E/AndroidRuntime(2666): ... 12 more