Android Camera2 API – 恢复时缺少权限

Android Camera2 API – 恢复时缺少权限,第1张

概述我正在使用Camera2 API开发应用程序.我的问题看起来像这样:  当我在相机片段工作时按下设备的睡眠按钮,之后我唤醒设备,应用程序重新启动 12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroidRuntime: FATAL EXCEPTION: main12-10 10:59:10.423 5081-50 我正在使用Camera2 API开发应用程序.我的问题看起来像这样:
 当我在相机片段工作时按下设备的睡眠按钮,之后我唤醒设备,应用程序重新启动

12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroIDRuntime: FATAL EXCEPTION: main12-10 10:59:10.423 5081-5081/com.snapsportz.nexus5camera.app E/AndroIDRuntime: Process: com.snapsportz.nexus5camera.app,PID: 508112-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 service12-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.handle@R_685_4404@Activity(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 service12-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.handle@R_685_4404@Activity(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) 

我相信它不是缺少清单文件中的相机权限,因为它包含在其中并且应用程序工作正常,除非我试图唤醒它.

任何暗示我都会很高兴.

解决方法@H_301_20@ 如果您使用的是Google Camera2Basic示例应用程序 – issue #42似乎描述了该问题.解决方案是在您的片段中检查您对onResume方法的使用 – 并在onResume()中调用openCamera()之前调用closeCamera().似乎在我的Camera2Basic测试中解决了这个问题. 总结

以上是内存溢出为你收集整理的Android Camera2 API – 恢复时缺少权限全部内容,希望文章能够帮你解决Android Camera2 API – 恢复时缺少权限所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1127972.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存