Skip to content Skip to sidebar Skip to footer

Trying To Switch Camera Back To Front But Getting Exception

Trying to switch camera back to front but getting exception. cant find the problem Please Check and help.. error:- 01-27 11:49:00.376: E/AndroidRuntime(30767): java.lang.RuntimeE

Solution 1:

Stop the camera previous instance before switching to other :

if (camera != null) {
        camera.stopPreview();
        camera.setPreviewCallback(null);
        camera.release();
        camera = null;
        surfaceholder.removeCallback(CameraActivity.this);
        surfaceholder = null;
}

And finish current camera activity, call start intent of same camera activity.

Solution 2:

First, destroy your surface, release the camera and recreate surface manually. Like this:

surfaceDestroy(holder);
surfaceCreated(holder);
surfaceChanged(holder,format,width,height); 

It solved my problem, it may help you.

Post a Comment for "Trying To Switch Camera Back To Front But Getting Exception"