gpt4 book ai didi

Android Camera2 API - 简历上缺乏特权

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:48 28 4
gpt4 key购买 nike

我正在使用 Camera2 API 开发应用程序。我的问题是这样的: 当我在相机 fragment 工作时按下设备的 sleep 按钮,然后我唤醒设备,应用程序重新启动

12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: FATAL EXCEPTION: main
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: Process: com.snapsportz.nexus5camera.app, PID: 5081
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: java.lang.RuntimeException: Unable to pause activity {com.snapsportz.nexus5camera.app/com.snapsportz.handheldcamera.app.CameraActivity}: java.lang.SecurityException: Lacking privileges to access camera service
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3381)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3340)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4047)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.-wrap15(ActivityThread.java)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: Caused by: java.lang.SecurityException: Lacking privileges to access camera service
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.hardware.camera2.utils.CameraBinderDecorator.throwOnError(CameraBinderDecorator.java:108)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.hardware.camera2.utils.CameraBinderDecorator$CameraBinderDecoratorListener.onAfterInvocation(CameraBinderDecorator.java:73)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.hardware.camera2.utils.Decorator.invoke(Decorator.java:81)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at java.lang.reflect.Proxy.invoke(Proxy.java:393)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at $Proxy1.cancelRequest(Unknown Source)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:899)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:373)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.snapsportz.handheldcamera.app.Camera2BasicFragment.closeCamera(Camera2BasicFragment.java:899)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.snapsportz.handheldcamera.app.Camera2BasicFragment.onPause(Camera2BasicFragment.java:771)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.Fragment.performPause(Fragment.java:2379)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1019)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:1967)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.FragmentController.dispatchPause(FragmentController.java:185)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.Activity.performPause(Activity.java:6346)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1311)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3367)
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3340) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4047) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.-wrap15(ActivityThread.java) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

我相信这不是 list 文件中缺少相机权限,因为它包含在 list 文件中并且应用程序运行正常,除非我尝试将其唤醒。

如果有任何提示,我将非常高兴。

最佳答案

如果您使用了 Google Camera2Basic 示例应用程序 - issue #42似乎描述了问题。解决方案是审查您对 onResume 的使用Fragment 中的方法- 并调用 closeCamera()在你打电话之前 openCamera()onResume() .似乎解决了我对 Camera2Basic 的测试中的问题.

关于Android Camera2 API - 简历上缺乏特权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34198994/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com