如何查找相机是否正在使用?

use*_*146 7 java camera android android-camera

有没有办法找到Android 相机是否在代码中使用?

COD*_*BOY 4

有什么办法可以知道android相机是否在使用中?

是的,如果相机正在使用中Camera.open(),会给你一个例外。

文档中,

/** 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
}
Run Code Online (Sandbox Code Playgroud)