我正在编写自己的具有某些功能的相机应用程序。我想在我的应用中使用android相机的标准场景模式。因为我要求通过以下所有支持的场景模式
Camera.Parameters.getSupportedSceneModes()
对于我的手机(荣誉8c),我拥有所有可用的场景模式,包括hdr。设置任何场景模式后,一切都OK,可以拍照了。但是在致电
之后Camera.Parameters parameters = mCamera.getParameters();
parameters.setSceneMode(scene_mode);
mCamera.setParameters(parameters);
然后过一段时间
mCamera.takePicture(shutterCallback, rawCallback, postviewCallback, mPicture);
我看到只有两个回调(快门和原始)有效,其他回调根本没有被调用。
调用takePicture方法后,我在Logcat中拥有的所有内容是:
D/MyApp: shutterCallback: works
D/MyApp: rawCallback: works
E/Camera: Error 1
我可以看到已拍摄照片并且相机的预览停止了,但是什么也没发生。
摄像机是否可能确实不支持hdr模式,但是getSupportedSceneModes会在支持的模式列表中返回hdr?如果是真的,那么如果该列表中有列表,该如何避免使用不受支持的场景模式?
也许在打开hdr模式时应该在快门或原始回调中做一些事情吗?
这是从调用setSceneMode方法开始的完整日志(Verbose和更高级别):
01-30 13:11:18.285 20980-20980/com.example.me.myapp V/AudioManager: playSoundEffect effectType: 0
01-30 13:11:18.352 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:18.352 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:18.353 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:18.353 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:18.367 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:18.367 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:18.368 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:18.368 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:18.388 20980-20980/com.example.me.myapp D/HwRTBlurUtils: check blur style for HwPhoneWindow, themeResId : 0x010302d7, context : android.view.ContextThemeWrapper@ba85eca, Nhwext : 0, get Blur : disable with , null
01-30 13:11:18.397 20980-21069/com.example.me.myapp D/OpenGLRenderer: HWUI Binary is disabled
01-30 13:11:18.405 20980-20987/com.example.me.myapp I/zygote64: Compiler allocated 4MB to compile void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
01-30 13:11:18.488 20980-20987/com.example.me.myapp I/zygote64: Do full code cache collection, code=222KB, data=196KB
01-30 13:11:18.489 20980-20987/com.example.me.myapp I/zygote64: After code cache collection, code=217KB, data=153KB
01-30 13:11:18.541 20980-20980/com.example.me.myapp I/ViewRootImpl: jank_removeInvalidNode all the node in jank list is out of time
01-30 13:11:18.543 20980-21069/com.example.me.myapp D/OpenGLRenderer: HWUI Binary is disabled
01-30 13:11:29.002 20980-20980/com.example.me.myapp I/ViewRootImpl: jank_removeInvalidNode all the node in jank list is out of time
01-30 13:11:29.075 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:29.075 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:29.076 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
01-30 13:11:29.076 20980-20980/com.example.me.myapp D/CubicBezierInterpolator: CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
01-30 13:11:30.161 20980-20980/com.example.me.myapp V/AudioManager: playSoundEffect effectType: 0
[ 01-30 13:11:30.168 26496:21400 I/ ]
~AppDegreeProfiles, destruction here
01-30 13:11:30.235 20980-20980/com.example.me.myapp V/InputMethodManager: Reporting focus gain, without startInput
这是调用takePicture方法后的日志:
01-30 13:11:56.211 20980-20980/com.example.me.myapp V/AudioManager: playSoundEffect effectType: 0
01-30 13:11:56.896 20980-20980/com.example.me.myapp D/MyApp: onShutter: works
01-30 13:11:56.896 20980-20980/com.example.me.myapp D/MyApp: previewCallback: works
01-30 13:12:05.614 20980-20980/com.example.me.myapp E/Camera: Error 1
仅此而已。然后,如果我隐藏我的应用并将其显示回去,则会看到以下日志:
01-30 13:22:46.065 20980-20980/com.example.me.myapp I/PermissionManager: camera remind result:true
01-30 13:22:46.070 20980-20980/com.example.me.myapp D/Error: Error setting camera preview: setPreviewTexture failed
01-30 13:22:46.071 20980-20980/com.example.me.myapp D/MyApp: surfaceChanged: stop Preview
01-30 13:22:46.155 20980-20980/com.example.me.myapp I/PermissionManager: camera remind result:true
01-30 13:22:46.156 20980-20980/com.example.me.myapp I/Camera: camera number: 2, for app: com.example.me.myapp
01-30 13:22:46.158 20980-20980/com.example.me.myapp D/Error: Error starting camera preview: startPreview failed
01-30 13:22:46.161 20980-20980/com.example.me.myapp W/InputMethodManager: startInputReason = 1
01-30 13:22:46.189 20980-20980/com.example.me.myapp I/ViewRootImpl: jank_removeInvalidNode all the node in jank list is out of time
01-30 13:23:12.579 20980-20980/com.example.me.myapp D/MyApp: surfaceDestroyed: stop Preview
01-30 13:23:14.081 20980-20980/com.example.me.myapp D/ActivityThread: Remove activity client record, r= ActivityRecord{ea46a70 token=android.os.BinderProxy@e78f13c {com.example.me.myapp/com.example.me.myapp.EnterActivity}} token= android.os.BinderProxy@e78f13c
01-30 13:23:14.115 20980-20980/com.example.me.myapp D/ActivityThread: Remove activity client record, r= ActivityRecord{69bcc36 token=android.os.BinderProxy@2eecac0 {com.example.me.myapp/com.example.me.myapp.CameraActivity}} token= android.os.BinderProxy@2eecac0
现在,在重新启动相机之前,我无法在其应用中使用相机。 没有例外,日志中只有错误消息。