public class

Camera.Parameters

extends Object
java.lang.Object
   ↳ android.hardware.Camera.Parameters

Class Overview

Camera service settings.

To make camera parameters take effect, applications have to call setParameters(Camera.Parameters). For example, after setWhiteBalance(String) is called, white balance is not actually changed until setParameters(Camera.Parameters) is called with the changed parameters object.

Different devices may have different camera capabilities, such as picture size or flash modes. The application should query the camera capabilities before setting parameters. For example, the application should call getSupportedColorEffects() before calling setColorEffect(String). If the camera does not support color effects, getSupportedColorEffects() will return null.

Summary

Constants
String ANTIBANDING_50HZ
String ANTIBANDING_60HZ
String ANTIBANDING_AUTO
String ANTIBANDING_OFF
String EFFECT_AQUA
String EFFECT_BLACKBOARD
String EFFECT_MONO
String EFFECT_NEGATIVE
String EFFECT_NONE
String EFFECT_POSTERIZE
String EFFECT_SEPIA
String EFFECT_SOLARIZE
String EFFECT_WHITEBOARD
String FLASH_MODE_AUTO Flash will be fired automatically when required.
String FLASH_MODE_OFF Flash will not be fired.
String FLASH_MODE_ON Flash will always be fired during snapshot.
String FLASH_MODE_RED_EYE Flash will be fired in red-eye reduction mode.
String FLASH_MODE_TORCH Constant emission of light during preview, auto-focus and snapshot.
int FOCUS_DISTANCE_FAR_INDEX The array index of far focus distance for use with getFocusDistances(float[]).
int FOCUS_DISTANCE_NEAR_INDEX The array index of near focus distance for use with getFocusDistances(float[]).
int FOCUS_DISTANCE_OPTIMAL_INDEX The array index of optimal focus distance for use with getFocusDistances(float[]).
String FOCUS_MODE_AUTO Auto-focus mode.
String FOCUS_MODE_CONTINUOUS_VIDEO Continuous auto focus mode intended for video recording.
String FOCUS_MODE_EDOF Extended depth of field (EDOF).
String FOCUS_MODE_FIXED Focus is fixed.
String FOCUS_MODE_INFINITY Focus is set at infinity.
String FOCUS_MODE_MACRO Macro (close-up) focus mode.
int PREVIEW_FPS_MAX_INDEX The array index of maximum preview fps for use with getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange().
int PREVIEW_FPS_MIN_INDEX The array index of minimum preview fps for use with getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange().
String SCENE_MODE_ACTION Take photos of fast moving objects.
String SCENE_MODE_AUTO Scene mode is off.
String SCENE_MODE_BARCODE Applications are looking for a barcode.
String SCENE_MODE_BEACH Take pictures on the beach.
String SCENE_MODE_CANDLELIGHT Capture the naturally warm color of scenes lit by candles.
String SCENE_MODE_FIREWORKS For shooting firework displays.
String SCENE_MODE_LANDSCAPE Take pictures on distant objects.
String SCENE_MODE_NIGHT Take photos at night.
String SCENE_MODE_NIGHT_PORTRAIT Take people pictures at night.
String SCENE_MODE_PARTY Take indoor low-light shot.
String SCENE_MODE_PORTRAIT Take people pictures.
String SCENE_MODE_SNOW Take pictures on the snow.
String SCENE_MODE_SPORTS Take photos of fast moving objects.
String SCENE_MODE_STEADYPHOTO Avoid blurry pictures (for example, due to hand shake).
String SCENE_MODE_SUNSET Take sunset photos.
String SCENE_MODE_THEATRE Take photos in a theater.
String WHITE_BALANCE_AUTO
String WHITE_BALANCE_CLOUDY_DAYLIGHT
String WHITE_BALANCE_DAYLIGHT
String WHITE_BALANCE_FLUORESCENT
String WHITE_BALANCE_INCANDESCENT
String WHITE_BALANCE_SHADE
String WHITE_BALANCE_TWILIGHT
String WHITE_BALANCE_WARM_FLUORESCENT
Public Methods
String flatten()
Creates a single string with all the parameters set in this Parameters object.
String get(String key)
Returns the value of a String parameter.
String getAntibanding()
Gets the current antibanding setting.
String getColorEffect()
Gets the current color effect setting.
int getExposureCompensation()
Gets the current exposure compensation index.
float getExposureCompensationStep()
Gets the exposure compensation step.
String getFlashMode()
Gets the current flash mode setting.
float getFocalLength()
Gets the focal length (in millimeter) of the camera.
void getFocusDistances(float[] output)
Gets the distances from the camera to where an object appears to be in focus.
String getFocusMode()
Gets the current focus mode setting.
float getHorizontalViewAngle()
Gets the horizontal angle of view in degrees.
int getInt(String key)
Returns the value of an integer parameter.
int getJpegQuality()
Returns the quality setting for the JPEG picture.
int getJpegThumbnailQuality()
Returns the quality setting for the EXIF thumbnail in Jpeg picture.
Camera.Size getJpegThumbnailSize()
Returns the dimensions for EXIF thumbnail in Jpeg picture.
int getMaxExposureCompensation()
Gets the maximum exposure compensation index.
int getMaxZoom()
Gets the maximum zoom value allowed for snapshot.
int getMinExposureCompensation()
Gets the minimum exposure compensation index.
int getPictureFormat()
Returns the image format for pictures.
Camera.Size getPictureSize()
Returns the dimension setting for pictures.
Camera.Size getPreferredPreviewSizeForVideo()
Returns the preferred or recommended preview size (width and height) in pixels for video recording.
int getPreviewFormat()
Returns the image format for preview frames got from Camera.PreviewCallback.
void getPreviewFpsRange(int[] range)
Returns the current minimum and maximum preview fps.
int getPreviewFrameRate()
This method is deprecated. replaced by getPreviewFpsRange(int[])
Camera.Size getPreviewSize()
Returns the dimensions setting for preview pictures.
String getSceneMode()
Gets the current scene mode setting.
List<String> getSupportedAntibanding()
Gets the supported antibanding values.
List<String> getSupportedColorEffects()
Gets the supported color effects.
List<String> getSupportedFlashModes()
Gets the supported flash modes.
List<String> getSupportedFocusModes()
Gets the supported focus modes.
List<Camera.Size> getSupportedJpegThumbnailSizes()
Gets the supported jpeg thumbnail sizes.
List<Integer> getSupportedPictureFormats()
Gets the supported picture formats.
List<Camera.Size> getSupportedPictureSizes()
Gets the supported picture sizes.
List<Integer> getSupportedPreviewFormats()
Gets the supported preview formats.
List<int[]> getSupportedPreviewFpsRange()
Gets the supported preview fps (frame-per-second) ranges.
List<Integer> getSupportedPreviewFrameRates()
This method is deprecated. replaced by getSupportedPreviewFpsRange()
List<Camera.Size> getSupportedPreviewSizes()
Gets the supported preview sizes.
List<String> getSupportedSceneModes()
Gets the supported scene modes.
List<Camera.Size> getSupportedVideoSizes()
Gets the supported video frame sizes that can be used by MediaRecorder.
List<String> getSupportedWhiteBalance()
Gets the supported white balance.
float getVerticalViewAngle()
Gets the vertical angle of view in degrees.
String getWhiteBalance()
Gets the current white balance setting.
int getZoom()
Gets current zoom value.
List<Integer> getZoomRatios()
Gets the zoom ratios of all zoom values.
boolean isSmoothZoomSupported()
Returns true if smooth zoom is supported.
boolean isZoomSupported()
Returns true if zoom is supported.
void remove(String key)
void removeGpsData()
Removes GPS latitude, longitude, altitude, and timestamp from the parameters.
void set(String key, String value)
Sets a String parameter.
void set(String key, int value)
Sets an integer parameter.
void setAntibanding(String antibanding)
Sets the antibanding.
void setColorEffect(String value)
Sets the current color effect setting.
void setExposureCompensation(int value)
Sets the exposure compensation index.
void setFlashMode(String value)
Sets the flash mode.
void setFocusMode(String value)
Sets the focus mode.
void setGpsAltitude(double altitude)
Sets GPS altitude.
void setGpsLatitude(double latitude)
Sets GPS latitude coordinate.
void setGpsLongitude(double longitude)
Sets GPS longitude coordinate.
void setGpsProcessingMethod(String processing_method)
Sets GPS processing method.
void setGpsTimestamp(long timestamp)
Sets GPS timestamp.
void setJpegQuality(int quality)
Sets Jpeg quality of captured picture.
void setJpegThumbnailQuality(int quality)
Sets the quality of the EXIF thumbnail in Jpeg picture.
void setJpegThumbnailSize(int width, int height)
Sets the dimensions for EXIF thumbnail in Jpeg picture.
void setPictureFormat(int pixel_format)
Sets the image format for pictures.
void setPictureSize(int width, int height)
Sets the dimensions for pictures.
void setPreviewFormat(int pixel_format)
Sets the image format for preview pictures.
void setPreviewFpsRange(int min, int max)
Sets the maximum and maximum preview fps.
void setPreviewFrameRate(int fps)
This method is deprecated. replaced by setPreviewFpsRange(int, int)
void setPreviewSize(int width, int height)
Sets the dimensions for preview pictures.
void setRotation(int rotation)
Sets the rotation angle in degrees relative to the orientation of the camera.
void setSceneMode(String value)
Sets the scene mode.
void setWhiteBalance(String value)
Sets the white balance.
void setZoom(int value)
Sets current zoom value.
void unflatten(String flattened)
Takes a flattened string of parameters and adds each one to this Parameters object.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ANTIBANDING_50HZ

Since: API Level 5

Constant Value: "50hz"

public static final String ANTIBANDING_60HZ

Since: API Level 5

Constant Value: "60hz"

public static final String ANTIBANDING_AUTO

Since: API Level 5

Constant Value: "auto"

public static final String ANTIBANDING_OFF

Since: API Level 5

Constant Value: "off"

public static final String EFFECT_AQUA

Since: API Level 5

Constant Value: "aqua"

public static final String EFFECT_BLACKBOARD

Since: API Level 5

Constant Value: "blackboard"

public static final String EFFECT_MONO

Since: API Level 5

Constant Value: "mono"

public static final String EFFECT_NEGATIVE

Since: API Level 5

Constant Value: "negative"

public static final String EFFECT_NONE

Since: API Level 5

Constant Value: "none"

public static final String EFFECT_POSTERIZE

Since: API Level 5

Constant Value: "posterize"

public static final String EFFECT_SEPIA

Since: API Level 5

Constant Value: "sepia"

public static final String EFFECT_SOLARIZE

Since: API Level 5

Constant Value: "solarize"

public static final String EFFECT_WHITEBOARD

Since: API Level 5

Constant Value: "whiteboard"

public static final String FLASH_MODE_AUTO

Since: API Level 5

Flash will be fired automatically when required. The flash may be fired during preview, auto-focus, or snapshot depending on the driver.

Constant Value: "auto"

public static final String FLASH_MODE_OFF

Since: API Level 5

Flash will not be fired.

Constant Value: "off"

public static final String FLASH_MODE_ON

Since: API Level 5

Flash will always be fired during snapshot. The flash may also be fired during preview or auto-focus depending on the driver.

Constant Value: "on"

public static final String FLASH_MODE_RED_EYE

Since: API Level 5

Flash will be fired in red-eye reduction mode.

Constant Value: "red-eye"

public static final String FLASH_MODE_TORCH

Since: API Level 5

Constant emission of light during preview, auto-focus and snapshot. This can also be used for video recording.

Constant Value: "torch"

public static final int FOCUS_DISTANCE_FAR_INDEX

Since: API Level 9

The array index of far focus distance for use with getFocusDistances(float[]).

Constant Value: 2 (0x00000002)

public static final int FOCUS_DISTANCE_NEAR_INDEX

Since: API Level 9

The array index of near focus distance for use with getFocusDistances(float[]).

Constant Value: 0 (0x00000000)

public static final int FOCUS_DISTANCE_OPTIMAL_INDEX

Since: API Level 9

The array index of optimal focus distance for use with getFocusDistances(float[]).

Constant Value: 1 (0x00000001)

public static final String FOCUS_MODE_AUTO

Since: API Level 5

Auto-focus mode. Applications should call autoFocus(AutoFocusCallback) to start the focus in this mode.

Constant Value: "auto"

public static final String FOCUS_MODE_CONTINUOUS_VIDEO

Since: API Level 9

Continuous auto focus mode intended for video recording. The camera continuously tries to focus. This is ideal for shooting video. Applications still can call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback) in this mode but the subject may not be in focus. Auto focus starts when the parameter is set. Applications should not call autoFocus(AutoFocusCallback) in this mode. To stop continuous focus, applications should change the focus mode to other modes.

Constant Value: "continuous-video"

public static final String FOCUS_MODE_EDOF

Since: API Level 8

Extended depth of field (EDOF). Focusing is done digitally and continuously. Applications should not call autoFocus(AutoFocusCallback) in this mode.

Constant Value: "edof"

public static final String FOCUS_MODE_FIXED

Since: API Level 5

Focus is fixed. The camera is always in this mode if the focus is not adjustable. If the camera has auto-focus, this mode can fix the focus, which is usually at hyperfocal distance. Applications should not call autoFocus(AutoFocusCallback) in this mode.

Constant Value: "fixed"

public static final String FOCUS_MODE_INFINITY

Since: API Level 5

Focus is set at infinity. Applications should not call autoFocus(AutoFocusCallback) in this mode.

Constant Value: "infinity"

public static final String FOCUS_MODE_MACRO

Since: API Level 5

Macro (close-up) focus mode. Applications should call autoFocus(AutoFocusCallback) to start the focus in this mode.

Constant Value: "macro"

public static final int PREVIEW_FPS_MAX_INDEX

Since: API Level 9

The array index of maximum preview fps for use with getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange().

Constant Value: 1 (0x00000001)

public static final int PREVIEW_FPS_MIN_INDEX

Since: API Level 9

The array index of minimum preview fps for use with getPreviewFpsRange(int[]) or getSupportedPreviewFpsRange().

Constant Value: 0 (0x00000000)

public static final String SCENE_MODE_ACTION

Since: API Level 5

Take photos of fast moving objects. Same as SCENE_MODE_SPORTS.

Constant Value: "action"

public static final String SCENE_MODE_AUTO

Since: API Level 5

Scene mode is off.

Constant Value: "auto"

public static final String SCENE_MODE_BARCODE

Since: API Level 8

Applications are looking for a barcode. Camera driver will be optimized for barcode reading.

Constant Value: "barcode"

public static final String SCENE_MODE_BEACH

Since: API Level 5

Take pictures on the beach.

Constant Value: "beach"

public static final String SCENE_MODE_CANDLELIGHT

Since: API Level 5

Capture the naturally warm color of scenes lit by candles.

Constant Value: "candlelight"

public static final String SCENE_MODE_FIREWORKS

Since: API Level 5

For shooting firework displays.

Constant Value: "fireworks"

public static final String SCENE_MODE_LANDSCAPE

Since: API Level 5

Take pictures on distant objects.

Constant Value: "landscape"

public static final String SCENE_MODE_NIGHT

Since: API Level 5

Take photos at night.

Constant Value: "night"

public static final String SCENE_MODE_NIGHT_PORTRAIT

Since: API Level 5

Take people pictures at night.

Constant Value: "night-portrait"

public static final String SCENE_MODE_PARTY

Since: API Level 5

Take indoor low-light shot.

Constant Value: "party"

public static final String SCENE_MODE_PORTRAIT

Since: API Level 5

Take people pictures.

Constant Value: "portrait"

public static final String SCENE_MODE_SNOW

Since: API Level 5

Take pictures on the snow.

Constant Value: "snow"

public static final String SCENE_MODE_SPORTS

Since: API Level 5

Take photos of fast moving objects. Same as SCENE_MODE_ACTION.

Constant Value: "sports"

public static final String SCENE_MODE_STEADYPHOTO

Since: API Level 5

Avoid blurry pictures (for example, due to hand shake).

Constant Value: "steadyphoto"

public static final String SCENE_MODE_SUNSET

Since: API Level 5

Take sunset photos.

Constant Value: "sunset"

public static final String SCENE_MODE_THEATRE

Since: API Level 5

Take photos in a theater. Flash light is off.

Constant Value: "theatre"

public static final String WHITE_BALANCE_AUTO

Since: API Level 5

Constant Value: "auto"

public static final String WHITE_BALANCE_CLOUDY_DAYLIGHT

Since: API Level 5

Constant Value: "cloudy-daylight"

public static final String WHITE_BALANCE_DAYLIGHT

Since: API Level 5

Constant Value: "daylight"

public static final String WHITE_BALANCE_FLUORESCENT

Since: API Level 5

Constant Value: "fluorescent"

public static final String WHITE_BALANCE_INCANDESCENT

Since: API Level 5

Constant Value: "incandescent"

public static final String WHITE_BALANCE_SHADE

Since: API Level 5

Constant Value: "shade"

public static final String WHITE_BALANCE_TWILIGHT

Since: API Level 5

Constant Value: "twilight"

public static final String WHITE_BALANCE_WARM_FLUORESCENT

Since: API Level 5

Constant Value: "warm-fluorescent"

Public Methods

public String flatten ()

Since: API Level 1

Creates a single string with all the parameters set in this Parameters object.

The unflatten(String) method does the reverse.

Returns
  • a String with all values from this Parameters object, in semi-colon delimited key-value pairs

public String get (String key)

Since: API Level 1

Returns the value of a String parameter.

Parameters
key the key name for the parameter
Returns
  • the String value of the parameter

public String getAntibanding ()

Since: API Level 5

Gets the current antibanding setting.

Returns
  • current antibanding. null if antibanding setting is not supported.

public String getColorEffect ()

Since: API Level 5

Gets the current color effect setting.

Returns
  • current color effect. null if color effect setting is not supported.

public int getExposureCompensation ()

Since: API Level 8

Gets the current exposure compensation index.

Returns

public float getExposureCompensationStep ()

Since: API Level 8

Gets the exposure compensation step.

Returns
  • exposure compensation step. Applications can get EV by multiplying the exposure compensation index and step. Ex: if exposure compensation index is -6 and step is 0.333333333, EV is -2.

public String getFlashMode ()

Since: API Level 5

Gets the current flash mode setting.

Returns
  • current flash mode. null if flash mode setting is not supported.

public float getFocalLength ()

Since: API Level 8

Gets the focal length (in millimeter) of the camera.

Returns
  • the focal length. This method will always return a valid value.

public void getFocusDistances (float[] output)

Since: API Level 9

Gets the distances from the camera to where an object appears to be in focus. The object is sharpest at the optimal focus distance. The depth of field is the far focus distance minus near focus distance. Focus distances may change after calling autoFocus(AutoFocusCallback), cancelAutoFocus(), or startPreview(). Applications can call getParameters() and this method anytime to get the latest focus distances. If the focus mode is FOCUS_MODE_CONTINUOUS_VIDEO, focus distances may change from time to time. This method is intended to estimate the distance between the camera and the subject. After autofocus, the subject distance may be within near and far focus distance. However, the precision depends on the camera hardware, autofocus algorithm, the focus area, and the scene. The error can be large and it should be only used as a reference. Far focus distance >= optimal focus distance >= near focus distance. If the focus distance is infinity, the value will be Float.POSITIVE_INFINITY.

Parameters
output focus distances in meters. output must be a float array with three elements. Near focus distance, optimal focus distance, and far focus distance will be filled in the array.

public String getFocusMode ()

Since: API Level 5

Gets the current focus mode setting.

Returns
  • current focus mode. This method will always return a non-null value. Applications should call autoFocus(AutoFocusCallback) to start the focus if focus mode is FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.

public float getHorizontalViewAngle ()

Since: API Level 8

Gets the horizontal angle of view in degrees.

Returns
  • horizontal angle of view. This method will always return a valid value.

public int getInt (String key)

Since: API Level 1

Returns the value of an integer parameter.

Parameters
key the key name for the parameter
Returns
  • the int value of the parameter

public int getJpegQuality ()

Since: API Level 5

Returns the quality setting for the JPEG picture.

Returns
  • the JPEG picture quality setting.

public int getJpegThumbnailQuality ()

Since: API Level 5

Returns the quality setting for the EXIF thumbnail in Jpeg picture.

Returns
  • the JPEG quality setting of the EXIF thumbnail.

public Camera.Size getJpegThumbnailSize ()

Since: API Level 5

Returns the dimensions for EXIF thumbnail in Jpeg picture.

Returns
  • a Size object with the height and width setting for the EXIF thumbnails

public int getMaxExposureCompensation ()

Since: API Level 8

Gets the maximum exposure compensation index.

Returns
  • maximum exposure compensation index (>=0). If both this method and getMinExposureCompensation() return 0, exposure compensation is not supported.

public int getMaxZoom ()

Since: API Level 8

Gets the maximum zoom value allowed for snapshot. This is the maximum value that applications can set to setZoom(int). Applications should call isZoomSupported() before using this method. This value may change in different preview size. Applications should call this again after setting preview size.

Returns
  • the maximum zoom value supported by the camera.

public int getMinExposureCompensation ()

Since: API Level 8

Gets the minimum exposure compensation index.

Returns
  • minimum exposure compensation index (<=0). If both this method and getMaxExposureCompensation() return 0, exposure compensation is not supported.

public int getPictureFormat ()

Since: API Level 1

Returns the image format for pictures.

Returns
  • the picture format
See Also

public Camera.Size getPictureSize ()

Since: API Level 1

Returns the dimension setting for pictures.

Returns
  • a Size object with the height and width setting for pictures

public Camera.Size getPreferredPreviewSizeForVideo ()

Since: API Level 11

Returns the preferred or recommended preview size (width and height) in pixels for video recording. Camcorder applications should set the preview size to a value that is not larger than the preferred preview size. In other words, the product of the width and height of the preview size should not be larger than that of the preferred preview size. In addition, we recommend to choose a preview size that has the same aspect ratio as the resolution of video to be recorded.

Returns
  • the preferred preview size (width and height) in pixels for video recording if getSupportedVideoSizes() does not return null; otherwise, null is returned.

public int getPreviewFormat ()

Since: API Level 1

Returns the image format for preview frames got from Camera.PreviewCallback.

Returns
  • the preview format.
See Also

public void getPreviewFpsRange (int[] range)

Since: API Level 9

Returns the current minimum and maximum preview fps. The values are one of the elements returned by getSupportedPreviewFpsRange().

Returns
  • range the minimum and maximum preview fps (scaled by 1000).

public int getPreviewFrameRate ()

Since: API Level 1

This method is deprecated.
replaced by getPreviewFpsRange(int[])

Returns the setting for the rate at which preview frames are received. This is the target frame rate. The actual frame rate depends on the driver.

Returns
  • the frame rate setting (frames per second)

public Camera.Size getPreviewSize ()

Since: API Level 1

Returns the dimensions setting for preview pictures.

Returns
  • a Size object with the width and height setting for the preview picture

public List<String> getSupportedAntibanding ()

Since: API Level 5

Gets the supported antibanding values.

Returns
  • a list of supported antibanding values. null if antibanding setting is not supported.
See Also

public List<String> getSupportedColorEffects ()

Since: API Level 5

Gets the supported color effects.

Returns
  • a list of supported color effects. null if color effect setting is not supported.
See Also

public List<String> getSupportedFlashModes ()

Since: API Level 5

Gets the supported flash modes.

Returns
  • a list of supported flash modes. null if flash mode setting is not supported.
See Also

public List<String> getSupportedFocusModes ()

Since: API Level 5

Gets the supported focus modes.

Returns
  • a list of supported focus modes. This method will always return a list with at least one element.
See Also

public List<Camera.Size> getSupportedJpegThumbnailSizes ()

Since: API Level 8

Gets the supported jpeg thumbnail sizes.

Returns
  • a list of Size object. This method will always return a list with at least two elements. Size 0,0 (no thumbnail) is always supported.

public List<Integer> getSupportedPictureFormats ()

Since: API Level 5

Gets the supported picture formats.

Returns
  • supported picture formats. This method will always return a list with at least one element.
See Also

public List<Camera.Size> getSupportedPictureSizes ()

Since: API Level 5

Gets the supported picture sizes.

Returns
  • a list of supported picture sizes. This method will always return a list with at least one element.

public List<Integer> getSupportedPreviewFormats ()

Since: API Level 5

Gets the supported preview formats.

Returns
  • a list of supported preview formats. This method will always return a list with at least one element.
See Also

public List<int[]> getSupportedPreviewFpsRange ()

Since: API Level 9

Gets the supported preview fps (frame-per-second) ranges. Each range contains a minimum fps and maximum fps. If minimum fps equals to maximum fps, the camera outputs frames in fixed frame rate. If not, the camera outputs frames in auto frame rate. The actual frame rate fluctuates between the minimum and the maximum. The values are multiplied by 1000 and represented in integers. For example, if frame rate is 26.623 frames per second, the value is 26623.

Returns
  • a list of supported preview fps ranges. This method returns a list with at least one element. Every element is an int array of two values - minimum fps and maximum fps. The list is sorted from small to large (first by maximum fps and then minimum fps).

public List<Integer> getSupportedPreviewFrameRates ()

Since: API Level 5

This method is deprecated.
replaced by getSupportedPreviewFpsRange()

Gets the supported preview frame rates.

Returns
  • a list of supported preview frame rates. null if preview frame rate setting is not supported.

public List<Camera.Size> getSupportedPreviewSizes ()

Since: API Level 5

Gets the supported preview sizes.

Returns
  • a list of Size object. This method will always return a list with at least one element.

public List<String> getSupportedSceneModes ()

Since: API Level 5

Gets the supported scene modes.

Returns
  • a list of supported scene modes. null if scene mode setting is not supported.
See Also

public List<Camera.Size> getSupportedVideoSizes ()

Since: API Level 11

Gets the supported video frame sizes that can be used by MediaRecorder. If the returned list is not null, the returned list will contain at least one Size and one of the sizes in the returned list must be passed to MediaRecorder.setVideoSize() for camcorder application if camera is used as the video source. In this case, the size of the preview can be different from the resolution of the recorded video during video recording.

Returns
  • a list of Size object if camera has separate preview and video output; otherwise, null is returned.

public List<String> getSupportedWhiteBalance ()

Since: API Level 5

Gets the supported white balance.

Returns
  • a list of supported white balance. null if white balance setting is not supported.

public float getVerticalViewAngle ()

Since: API Level 8

Gets the vertical angle of view in degrees.

Returns
  • vertical angle of view. This method will always return a valid value.

public String getWhiteBalance ()

Since: API Level 5

Gets the current white balance setting.

Returns
  • current white balance. null if white balance setting is not supported.

public int getZoom ()

Since: API Level 8

Gets current zoom value. This also works when smooth zoom is in progress. Applications should check isZoomSupported() before using this method.

Returns
  • the current zoom value. The range is 0 to getMaxZoom(). 0 means the camera is not zoomed.

public List<Integer> getZoomRatios ()

Since: API Level 8

Gets the zoom ratios of all zoom values. Applications should check isZoomSupported() before using this method.

Returns
  • the zoom ratios in 1/100 increments. Ex: a zoom of 3.2x is returned as 320. The number of elements is getMaxZoom() + 1. The list is sorted from small to large. The first element is always 100. The last element is the zoom ratio of the maximum zoom value.

public boolean isSmoothZoomSupported ()

Since: API Level 8

Returns true if smooth zoom is supported. Applications should call this before using other smooth zoom methods.

Returns
  • true if smooth zoom is supported.

public boolean isZoomSupported ()

Since: API Level 8

Returns true if zoom is supported. Applications should call this before using other zoom methods.

Returns
  • true if zoom is supported.

public void remove (String key)

Since: API Level 1

public void removeGpsData ()

Since: API Level 5

Removes GPS latitude, longitude, altitude, and timestamp from the parameters.

public void set (String key, String value)

Since: API Level 1

Sets a String parameter.

Parameters
key the key name for the parameter
value the String value of the parameter

public void set (String key, int value)

Since: API Level 1

Sets an integer parameter.

Parameters
key the key name for the parameter
value the int value of the parameter

public void setAntibanding (String antibanding)

Since: API Level 5

Sets the antibanding.

Parameters
antibanding new antibanding value.
See Also

public void setColorEffect (String value)

Since: API Level 5

Sets the current color effect setting.

Parameters
value new color effect.
See Also

public void setExposureCompensation (int value)

Since: API Level 8

Sets the exposure compensation index.

Parameters
value exposure compensation index. The valid value range is from getMinExposureCompensation() (inclusive) to getMaxExposureCompensation() (inclusive). 0 means exposure is not adjusted. Application should call getMinExposureCompensation and getMaxExposureCompensation to know if exposure compensation is supported.

public void setFlashMode (String value)

Since: API Level 5

Sets the flash mode.

Parameters
value flash mode.
See Also

public void setFocusMode (String value)

Since: API Level 5

Sets the focus mode.

Parameters
value focus mode.
See Also

public void setGpsAltitude (double altitude)

Since: API Level 5

Sets GPS altitude. This will be stored in JPEG EXIF header.

Parameters
altitude GPS altitude in meters.

public void setGpsLatitude (double latitude)

Since: API Level 5

Sets GPS latitude coordinate. This will be stored in JPEG EXIF header.

Parameters
latitude GPS latitude coordinate.

public void setGpsLongitude (double longitude)

Since: API Level 5

Sets GPS longitude coordinate. This will be stored in JPEG EXIF header.

Parameters
longitude GPS longitude coordinate.

public void setGpsProcessingMethod (String processing_method)

Since: API Level 8

Sets GPS processing method. It will store up to 32 characters in JPEG EXIF header.

Parameters
processing_method The processing method to get this location.

public void setGpsTimestamp (long timestamp)

Since: API Level 5

Sets GPS timestamp. This will be stored in JPEG EXIF header.

Parameters
timestamp GPS timestamp (UTC in seconds since January 1, 1970).

public void setJpegQuality (int quality)

Since: API Level 5

Sets Jpeg quality of captured picture.

Parameters
quality the JPEG quality of captured picture. The range is 1 to 100, with 100 being the best.

public void setJpegThumbnailQuality (int quality)

Since: API Level 5

Sets the quality of the EXIF thumbnail in Jpeg picture.

Parameters
quality the JPEG quality of the EXIF thumbnail. The range is 1 to 100, with 100 being the best.

public void setJpegThumbnailSize (int width, int height)

Since: API Level 5

Sets the dimensions for EXIF thumbnail in Jpeg picture. If applications set both width and height to 0, EXIF will not contain thumbnail. Applications need to consider the display orientation. See setPreviewSize(int, int) for reference.

Parameters
width the width of the thumbnail, in pixels
height the height of the thumbnail, in pixels

public void setPictureFormat (int pixel_format)

Since: API Level 1

Sets the image format for pictures.

Parameters
pixel_format the desired picture format (ImageFormat.NV21, ImageFormat.RGB_565, or ImageFormat.JPEG)
See Also

public void setPictureSize (int width, int height)

Since: API Level 1

Sets the dimensions for pictures. Applications need to consider the display orientation. See setPreviewSize(int, int) for reference.

Parameters
width the width for pictures, in pixels
height the height for pictures, in pixels

public void setPreviewFormat (int pixel_format)

Since: API Level 1

Sets the image format for preview pictures.

If this is never called, the default format will be NV21, which uses the NV21 encoding format.

Parameters
pixel_format the desired preview picture format, defined by one of the ImageFormat constants. (E.g., ImageFormat.NV21 (default), ImageFormat.RGB_565, or ImageFormat.JPEG)
See Also

public void setPreviewFpsRange (int min, int max)

Since: API Level 9

Sets the maximum and maximum preview fps. This controls the rate of preview frames received in Camera.PreviewCallback. The minimum and maximum preview fps must be one of the elements from getSupportedPreviewFpsRange().

Parameters
min the minimum preview fps (scaled by 1000).
max the maximum preview fps (scaled by 1000).
Throws
RuntimeException if fps range is invalid.

public void setPreviewFrameRate (int fps)

Since: API Level 1

This method is deprecated.
replaced by setPreviewFpsRange(int, int)

Sets the rate at which preview frames are received. This is the target frame rate. The actual frame rate depends on the driver.

Parameters
fps the frame rate (frames per second)

public void setPreviewSize (int width, int height)

Since: API Level 1

Sets the dimensions for preview pictures. The sides of width and height are based on camera orientation. That is, the preview size is the size before it is rotated by display orientation. So applications need to consider the display orientation while setting preview size. For example, suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size.

Parameters
width the width of the pictures, in pixels
height the height of the pictures, in pixels

public void setRotation (int rotation)

Since: API Level 5

Sets the rotation angle in degrees relative to the orientation of the camera. This affects the pictures returned from JPEG Camera.PictureCallback. The camera driver may set orientation in the EXIF header without rotating the picture. Or the driver may rotate the picture and the EXIF thumbnail. If the Jpeg picture is rotated, the orientation in the EXIF header will be missing or 1 (row #0 is top and column #0 is left side).

If applications want to rotate the picture to match the orientation of what users see, apps should use OrientationEventListener and Camera.CameraInfo. The value from OrientationEventListener is relative to the natural orientation of the device. CameraInfo.orientation is the angle between camera orientation and natural device orientation. The sum of the two is the rotation angle for back-facing camera. The difference of the two is the rotation angle for front-facing camera. Note that the JPEG pictures of front-facing cameras are not mirrored as in preview display.

For example, suppose the natural orientation of the device is portrait. The device is rotated 270 degrees clockwise, so the device orientation is 270. Suppose a back-facing camera sensor is mounted in landscape and the top side of the camera sensor is aligned with the right edge of the display in natural orientation. So the camera orientation is 90. The rotation should be set to 0 (270 + 90).

The reference code is as follows.

 public void public void onOrientationChanged(int orientation) {
     if (orientation == ORIENTATION_UNKNOWN) return;
     android.hardware.Camera.CameraInfo info =
            new android.hardware.Camera.CameraInfo();
     android.hardware.Camera.getCameraInfo(cameraId, info);
     orientation = (orientation + 45) / 90 * 90;
     int rotation = 0;
     if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
         rotation = (info.orientation - orientation + 360) % 360;
     } else {  // back-facing camera
         rotation = (info.orientation + orientation) % 360;
     }
     mParameters.setRotation(rotation);
 }
 

Parameters
rotation The rotation angle in degrees relative to the orientation of the camera. Rotation can only be 0, 90, 180 or 270.
Throws
IllegalArgumentException if rotation value is invalid.

public void setSceneMode (String value)

Since: API Level 5

Sets the scene mode. Changing scene mode may override other parameters (such as flash mode, focus mode, white balance). For example, suppose originally flash mode is on and supported flash modes are on/off. In night scene mode, both flash mode and supported flash mode may be changed to off. After setting scene mode, applications should call getParameters to know if some parameters are changed.

Parameters
value scene mode.
See Also

public void setWhiteBalance (String value)

Since: API Level 5

Sets the white balance.

Parameters
value new white balance.

public void setZoom (int value)

Since: API Level 8

Sets current zoom value. If the camera is zoomed (value > 0), the actual picture size may be smaller than picture size setting. Applications can check the actual picture size after picture is returned from Camera.PictureCallback. The preview size remains the same in zoom. Applications should check isZoomSupported() before using this method.

Parameters
value zoom value. The valid range is 0 to getMaxZoom().

public void unflatten (String flattened)

Since: API Level 1

Takes a flattened string of parameters and adds each one to this Parameters object.

The flatten() method does the reverse.

Parameters
flattened a String of parameters (key-value paired) that are semi-colon delimited