How to find whether the camera is in use?
android, android-camera, camera, java
Solution
Is there any way to find whether the android camera is in use?
Yes, `Camera.open()` will give you an Exception if Camera is in use.
From the docs,
/** 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
}
Problem
Is there any way to find whether the Android Camera is in use in code?