0

I am doing a project related to live wallpaper, in that camera was set as wallpaper, so in my app camera was running continuously, if user set camera as wallpaper, after he opening the camera it will shows the camera failed to load error, so, i am using the following code to avoid this error:

public void onVisibilityChanged(boolean visible) {
          if (visible){
            try {   
                    mCamera.reconnect();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
        }
        else{
            try {
                mCamera.unlock();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

 }

But my problem is could not unlock the camera object to other apps use the camera.

can any one give me an idea how can i do this?

Somanadh
  • 97
  • 2
  • 11

2 Answers2

0

You cannot access the object used by the native camera app or other apps to access camera. When you create mCamera, you are creating your own object which is used by your app. At a time, only one object can access a particular camera resource, and you have no control over other objects of other apps accessing that camera resource.

If you want avoid the failed to load error, you need to release your camera object before you open another app which uses camera resource. But then I do not think your main objective will be accomplished.

SoulRayder
  • 5,072
  • 6
  • 47
  • 93
0

I am using same method with small modifications to solve the issue, i was doing following changes in the code

public void onVisibilityChanged(boolean visible) {
        // TODO Auto-generated method stub
        super.onVisibilityChanged(visible);
        if (visible) {
            try {
                "open camera object"
            }catch (Exception e) {
                    e.printStackTrace();
            }
        }else {
            try {
                 "release the camera object"
            }catch (RuntimeException e) {
                 e.printStackTrace();
            }
        }
    }
Somanadh
  • 97
  • 2
  • 11