简体   繁体   English

检查Android 1.6上的摄像头(SDK 4)

[英]Check for camera on Android 1.6 (SDK 4)

I have searched this server for the answer to this question but I haven't found one. 我在这个服务器上搜索了这个问题的答案,但我还没找到。 I have only found it for Android 2.0 (SDK 5) . 我只发现它适用于Android 2.0(SDK 5) So does anybody know how to find out whether there is a camera in Android 1.6 application? 那么有谁知道如何找出Android 1.6应用程序中是否有相机? Can I check if the camera has autofocus. 我可以检查相机是否有自动对焦。

Thank you for your answers, saric. 谢谢你的答案,saric。

Here is code to check if there is a camera ( https://developer.android.com/guide/topics/media/camera.html ): 以下是检查是否有相机的代码( https://developer.android.com/guide/topics/media/camera.html ):

/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
    Camera c = null;
    try {
        c = Camera.open(); // attempt to get a Camera instance
    }
    catch (Exception e){
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}

From the Android Compatibility page ( https://developer.android.com/guide/practices/compatibility.html ): 从Android兼容性页面( https://developer.android.com/guide/practices/compatibility.html ):

Android 1.0 through 1.5 required a 2 megapixel camera with auto-focus. Android 1.0到1.5需要一个200万像素的自动对焦相机。 However, with version 1.6, Android devices were permitted to omit the auto-focus capability, though a (fixed-focus) camera was still required. 但是,对于1.6版本,允许Android设备省略自动对焦功能,但仍需要(固定焦距)相机。 Some apps such as barcode scanners do not function as well with cameras that do not auto-focus. 某些应用程序(如条形码扫描仪)不能与不自动对焦的相机一起使用。 To prevent users from having a bad experience with those apps, existing apps that obtain permission to use the Camera were assumed by default to require auto-focus. 为了防止用户使用这些应用程序获得不良体验,默认情况下,假定获得使用相机权限的现有应用程序需要自动对焦。 This allowed Google Play to filter those apps from devices that lack auto-focus. 这样,Google Play就可以从缺少自动对焦的设备中过滤这些应用。

Looking at the API here: https://developer.android.com/reference/android/hardware/Camera.html#autoFocus%28android.hardware.Camera.AutoFocusCallback%29 在这里查看API: https//developer.android.com/reference/android/hardware/Camera.html#autoFocus%28android.hardware.Camera.AutoFocusCallback%29

It looks like they tell you to use a function that isn't present yet. 看起来他们告诉你使用一个尚未出现的功能。

Unfortunately it may not be possible to check if the camera has auto-focus in Android 1.6. 不幸的是,可能无法检查相机是否在Android 1.6中自动对焦。

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

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