0
        // Just in case the camera is used at the moment, release it first 
        mCamera.release();
        mCamera = getCameraInstance();
        mCamera.setDisplayOrientation(90);
 
        mMediaRecorder = new MediaRecorder();
 
        // The next steps have to be in this exact order 
        // Step 1: Unlock and set camera to MediaRecorder 
        mCamera.unlock();
        mMediaRecorder.setCamera(mCamera);
 
        // Step 2: Set sources 
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
 
        // Step 3: Set a CamcorderProfile (requires API Level 8 or higher) 
        // mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
        // mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 
        // mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); 
        mMediaRecorder.setProfile(CamcorderProfile
                .get(CamcorderProfile.QUALITY_HIGH));
 
        // Step 4: Set output file 
        setOutputFiles(); 
        mMediaRecorder.setOutputFile(Mediafile.toString());
 
        // Step 5: Set the preview output 
        mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
         
        // Set OrientationHint of mMediaRecorder according to the actual rotation of the phone 
        mMediaRecorder.setOrientationHint(getRotation());
 
        // Step 6: Prepare configured MediaRecorder 
        try { 
            mMediaRecorder.prepare();
        } catch (IllegalStateException e) {
            Log.d("TAG",
                    "IllegalStateException preparing MediaRecorder: " 
                            + e.getMessage());
            releaseMediaRecorder(); 
            return false; 
        } catch (IOException e) {
            Log.d("TAG",
                    "IOException preparing MediaRecorder: " + e.getMessage());
            releaseMediaRecorder(); 
            return false; 
        } 
        return true; 
    } 
 
    /** 
     * Return the rotation angle for the mediaRecorder.setOrientationHint method 
     *  
     * @return an {@link Integer} roundet to 0, 90, 180 or 270 degree 
     */ 
    private int getRotation() { 
        return degree > 0 && degree <= 90 ? 270
                : degree > 90 && degree <= 180 ? 0 : degree > 180
                        && degree <= 270 ? 90 : 180;
    } 
 
    /** 
     * Release the current {@link MediaRecorder} object and lock the {@link Camera} object for later 
     * use. 
     */ 
    private void releaseMediaRecorder() { 
        if (mMediaRecorder != null) {
            mMediaRecorder.reset(); // clear recorder configuration
            mMediaRecorder.release(); // release the recorder object
            mMediaRecorder = null;
            mCamera.lock(); // lock camera for later use
        } 
    }