Sumit Joshi
Sumit Joshi

Reputation: 11

Can we use front camera in two apps concurrently in android?

I want to record a video call made on skype on android phone. But when the call gets connected i start my app which record the video. But it troughs an error (My app cant start recording) "java.lang.RuntimeException: Fail to connect to camera service"

Upvotes: 1

Views: 1148

Answers (2)

Daniël van den Berg
Daniël van den Berg

Reputation: 2355

http://developer.android.com/guide/topics/media/camera.html states the following: Accessing cameras

If you have determined that the device on which your application is running has a camera, you must request to access it by getting an instance of Camera (unless you are using an intent to access the camera).

To access the primary camera, use the Camera.open() method and be sure to catch any exceptions, as shown in the code below:

/** 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
}

// Camera is not available (in use or does not exist)

So, simply said, your answer is no.

Upvotes: 1

Bryan Herbst
Bryan Herbst

Reputation: 67189

The camera can only be used by one application at a time.

As per the open() documentation:

Creates a new Camera object to access a particular hardware camera. If the same camera is opened by other applications, this will throw a RuntimeException.

Upvotes: 3

Related Questions