简体   繁体   English

getCameraIdList()函数返回一个空数组

[英]getCameraIdList() function returns an empty array

I'm trying to work with Android's camera API 2, and I had a bug which I wasn't able to fix. 我正在尝试使用Android的相机API 2,但遇到了一个无法修复的错误。 The function getCameraIdList() returns an empty array for some reason, although I do have 2 working cameras on my emulator (I checked it using the Android camera app). 尽管我在模拟器上确实有2个工作的摄像头(我使用Android摄像头应用程序对其进行了检查),但由于某种原因,函数getCameraIdList()返回空数组。 I am working on an emulated device with the following details: Device: Nexus S API level: androd 4.4.2, API level 19 CPU: intel atom x86 front & back camera are emulated 我正在使用以下详细信息模拟设备:设备:Nexus S API级别:androd 4.4.2,API级别19 CPU:英特尔Atom X86前置和后置摄像头均被仿真

what do you think? 你怎么看? attached is the code. 附带的是代码。

private CameraManager mManager;
private String[] mCameraIds;
mManager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);
mCameraIds = mManager.getCameraIdList();

函数getCameraIdList仅适用于Android API版本21

Here are four things that might get the app to start working again. 这里有四件事可能会使应用程序重新开始工作。 One of these four have always done the trick for me when the I get the error. 当我收到错误消息时,这四个中的一个总是对我有用。

  1. Switch to another app and then back to the camera app. 切换到另一个应用程序,然后再返回相机应用程序。
    Hit the back button to exit the camera app and then tap to open it again. 点击后退按钮退出相机应用程序,然后点击以再次打开它。 This has the least success rate, to be honest, but it does work and it's the quickest solution. 坦率地说,这具有最低的成功率,但是它确实有效,并且是最快的解决方案。
  2. Exit all apps that might be using the camera. 退出所有可能正在使用相机的应用程序。 Go to Settings>Battery and check if mm-qcamera-daemon is running. 转到“设置”>“电池”,然后检查mm-qcamera-daemon是否正在运行。 Exit it and launch the app again to see if the camera connects. 退出并再次启动应用程序以查看相机是否连接。
  3. Exit the app and relaunch it. 退出应用程序,然后重新启动。 This works most times. 这大多数时候都有效。 If it doesn't try to force stop the app and clear the cache. 如果没有尝试强制停止应用程序并清除缓存。 The measures sound drastic but it has a high success rate. 这些措施听起来很严厉,但成功率很高。
  4. If all else fails, restart your phone. 如果其他所有方法均失败,请重新启动手机。
    Exit every app that's running before restart it. 退出每个正在运行的应用程序,然后重新启动它。 I found this to work when nothing else would and so far the error hasn't popped up again. 我发现此方法在没有其他办法的情况下仍有效,并且到目前为止该错误没有再次弹出。

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

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