Code example for Camera

Methods: getParameterssetParameterssetPreviewDisplaystartPreviewstopPreview

0
            return; 
        } 
 
        // stop preview before making changes 
        try { 
            mCamera.stopPreview();
        } catch (final Exception e) {
            // ignore: tried to stop a non-existent preview 
        } 
 
        final Parameters p = mCamera.getParameters();
 
        Camera.Size size = getBestPreviewSize(w, h, p, mForceAspectRatio);
 
        // This means our screen is probably small and there are no pixel-for-pixel preview sizes 
        // that have the same aspect ratio. Try searching from the original picture size and letting 
        // the UI scale. 
        if (size == null) {
            Log.w(TAG,
                    "Couldn't find the best size that maps pixel-for-pixel on the screen. Trying larger ones..."); 
            final Size picSize = p.getPictureSize();
            size = getBestPreviewSize(picSize.width, picSize.height, p, (float) picSize.width
                    / picSize.height);
        } 
 
        // ok, this isn't good. But it's better than failing. 
        if (size == null) {
            Log.e(TAG,
                    "Trying to find the best size, but couldn't find one with the request aspect ratio (" 
                            + mForceAspectRatio + "). Ignoring ratio request...");
            size = getBestPreviewSize(w, h, p, 0f);
        } 
 
        p.setPreviewSize(size.width, size.height);
 
        mCamera.setParameters(p);
 
        // start preview with new settings 
        try { 
            mCamera.setPreviewDisplay(mHolder);
            mCamera.startPreview();
            if (mOnPreviewStartedListener != null) {
                mOnPreviewStartedListener.onPreviewStarted();
            } 
 
        } catch (final Exception e) {