简体   繁体   English

CWAC相机的autofocus()和闪光模式问题

[英]CWAC camera autofocus() and flashmodes issue

I am using a Xiaomi RedMi running Android 4.4.4. 我正在使用运行Android 4.4.4的Xiaomi RedMi。 I am using the demo project as a reference for my DemoCameraFragment. 我正在使用演示项目作为DemoCameraFragment的参考。 When the camera starts up the first time, isAutofocusAvailable() returns false. 相机第一次启动时,isAutofocusAvailable()返回false。 After taking the first pic in SingleShotMode, I click on my "take next pic button" in which I call restartPreview(). 在SingleShotMode中拍摄了第一张照片后,我单击“拍摄下一张照片按钮”,在其中调用restartPreview()。 For some reason, isAutofocusAvailable() now returns true and I can call autofocus successfully. 由于某种原因,isAutofocusAvailable()现在返回true,我可以成功调用自动对焦。

Now when I call getFlashMode(), when my app starts I get a Null Pointer Exception(Which I think occurs on the camera object). 现在,当我调用getFlashMode()时,当我的应用程序启动时,我会得到一个Null Pointer Exception(我认为这发生在camera对象上)。 However, after I take the first pic and click on the "take next pic" button"( I call restartPreview() here), getFlashMode() no longer gives me a null pointer exception. 但是,在我拍摄了第一张图片并单击“拍摄下一张图片”按钮之后(在这里我称为restartPreview()),getFlashMode()不再为我提供空指针异常。

What exactly am I missing out setup-wise? 我究竟在设置方面错过了什么? I am using Android Annotations so my first call to both autofocus and getFlashMode is in @AfterViews annotated function. 我正在使用Android注释,因此我对自动对焦和getFlashMode的第一个调用是在@AfterViews注释函数中。 Why are Autofocus and getFlashMode not working for the first call? 为什么自动对焦和getFlashMode不能在第一个呼叫中使用?

kotlin

cameraView.setOnClickListener{
    cameraView.autoFocus()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM