我想做一個簡單的手電筒應用程序,當我測試時,應用程序崩潰。我認爲嘗試訪問相機時出現了問題。有什麼建議麼?訪問相機時發生崩潰?
W/CameraBase: An error occurred while connecting to camera: 0
W/CameraBase: An error occurred while connecting to camera: 0
W/CameraBase: An error occurred while connecting to camera: 0
W/CameraBase: An error occurred while connecting to camera: 0
W/CameraBase: An error occurred while connecting to camera: 0
I/Camera2Mode: fail
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.open(Camera.java:479)
at android.hardware.Camera.open(Camera.java:547)
at android.view.View.performClick(View.java:5226)
at android.widget.CompoundButton.performClick(CompoundButton.java:122)
at android.view.View$PerformClick.run(View.java:21266)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
D/Process: killProcess, pid=23317
D/Process: com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException:113 java.lang.ThreadGroup.uncaughtException:693 java.lang.ThreadGroup.uncaughtException:690
Disconnected from the target VM, address: 'localhost:8603', transport: 'socket'
請張貼你的清單代碼。你給那些權限? –
stackoverflow.com/questions/23904459/android-java-lang-runtimeexception-fail-to-connect-to-camera-service –