public final class

Camera

extends Object
java.lang.Object
   ↳ com.neomades.media.Camera

Class Overview

Camera features to take pictures or videos.

To use this class, the CAMERA permission must be declared in the URS file.

See Also

Summary

Public Methods
static Camera getDefault()
Returns the default camera device.
static boolean hasCamera()
Returns if the device has a camera feature.
static boolean hasGallery()
Returns if the device has a gallery feature.
Camera setActionTitle(int textResID)
Sets the title of the dialog allowing to choose between the camera application and the gallery.
Camera setActionTitle(String text)
Sets the title of the dialog allowing to choose between the camera application and the gallery.
Camera setCameraActionText(int textResID)
Sets the text for the action "Camera" button.
Camera setCameraActionText(String text)
Sets the text for the action "Camera" button.
Camera setCancelActionText(String text)
Sets the text for the action "Cancel" button.
Camera setCancelActionText(int textResID)
Sets the text for the action "Cancel" button.
Camera setGalleryActionText(String text)
Sets the text for the action "Gallery" button.
Camera setGalleryActionText(int textResID)
Sets the text for the action "Gallery" button.
Camera setPauseActionText(int textResID)
Sets the text for the action "Pause" button.
Camera setPauseActionText(String text)
Sets the text for the action "Pause" button.
Camera setPlayActionText(int textResID)
Sets the text for the action "Play" button.
Camera setPlayActionText(String text)
Sets the text for the action "Play" button.
Camera setRecordActionText(String text)
Sets the text for the action "Record" button.
Camera setRecordActionText(int textResID)
Sets the text for the action "Record" button.
Camera setSelectActionText(int textResID)
Sets the text for the action "Select" button.
Camera setSelectActionText(String text)
Sets the text for the action "Select" button.
Camera setStopActionText(String text)
Sets the text for the action "Stop" button.
Camera setStopActionText(int textResID)
Sets the text for the action "Stop" button.
void takePicture(CameraListener callback)
Opens a dialog giving the user the choice to launch whether a picture gallery or a camera application to take a picture.
void takePictureFromCamera(CameraListener callback)
Launches application chooser for the user to choose a camera application to take a picture.
void takePictureFromGallery(CameraListener callback)
Launches application chooser for the user to choose a gallery application to choose a picture.
void takeVideo(CameraListener callback)
Opens a dialog giving the user the choice to launch whether a picture gallery or a camera application to take a video.
void takeVideoFromCamera(CameraListener callback)
Launches application chooser for the user to choose a camera application to take a video.
void takeVideoFromGallery(CameraListener callback)
Launches application chooser for the user to choose a gallery application to choose a video.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Camera getDefault ()

Returns the default camera device.

If the CAMERA permission is not declared, calling this method may throw a SecurityException.

Returns
  • the default camera device

public static boolean hasCamera ()

Returns if the device has a camera feature.

If the CAMERA permission is not declared, calling this method may throw a SecurityException.

Returns
  • true if the device has Camera feature accessible from application.

public static boolean hasGallery ()

Returns if the device has a gallery feature.

If the PHOTO_LIBRARY permission is not declared, calling this method may throw a SecurityException.

Returns
  • true if the device has gallery feature accessible from application.

public Camera setActionTitle (int textResID)

Sets the title of the dialog allowing to choose between the camera application and the gallery. This dialog is used by the following platforms :

  • iOS
  • Android

Default text is : "Select source application"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the title to set.
Returns
  • the Camera instance

public Camera setActionTitle (String text)

Sets the title of the dialog allowing to choose between the camera application and the gallery. This dialog is used by the following platforms :

  • iOS
  • Android

Default text is : "Select source application"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the title to set.
Returns
  • the Camera instance

public Camera setCameraActionText (int textResID)

Sets the text for the action "Camera" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Camera"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the camera action name to set.
Returns
  • the Camera instance

public Camera setCameraActionText (String text)

Sets the text for the action "Camera" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Camera"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the camera action name to set.
Returns
  • the Camera instance

public Camera setCancelActionText (String text)

Sets the text for the action "Cancel" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Cancel"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the cancel action name to set.
Returns
  • the Camera instance

public Camera setCancelActionText (int textResID)

Sets the text for the action "Cancel" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Cancel"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the cancel action name to set.
Returns
  • the Camera instance

public Camera setGalleryActionText (String text)

Sets the text for the action "Gallery" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Gallery"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the gallery action name to set.
Returns
  • the Camera instance

public Camera setGalleryActionText (int textResID)

Sets the text for the action "Gallery" button. This dialog is used by the following platforms :

  • iOS

Default text is : "Gallery"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the gallery action name to set.
Returns
  • the Camera instance

public Camera setPauseActionText (int textResID)

Sets the text for the action "Pause" button. This dialog is used by the following platforms :

Default text is : "Pause"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the pause action name to set.
Returns
  • the Camera instance

public Camera setPauseActionText (String text)

Sets the text for the action "Pause" button. This dialog is used by the following platforms :

Default text is : "Pause"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the pause action name to set.
Returns
  • the Camera instance

public Camera setPlayActionText (int textResID)

Sets the text for the action "Play" button. This dialog is used by the following platforms :

Default text is : "Play"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the play action name to set.
Returns
  • the Camera instance

public Camera setPlayActionText (String text)

Sets the text for the action "Play" button. This dialog is used by the following platforms :

Default text is : "Play"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the play action name to set.
Returns
  • the Camera instance

public Camera setRecordActionText (String text)

Sets the text for the action "Record" button. This dialog is used by the following platforms :

Default text is : "Record"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the record action name to set.
Returns
  • the Camera instance

public Camera setRecordActionText (int textResID)

Sets the text for the action "Record" button. This dialog is used by the following platforms :

Default text is : "Record"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the record action name to set.
Returns
  • the Camera instance

public Camera setSelectActionText (int textResID)

Sets the text for the action "Select" button. This dialog is used by the following platforms :

Default text is : "Select"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the select action name to set.
Returns
  • the Camera instance

public Camera setSelectActionText (String text)

Sets the text for the action "Select" button. This dialog is used by the following platforms :

Default text is : "Select"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the select action name to set.
Returns
  • the Camera instance

public Camera setStopActionText (String text)

Sets the text for the action "Stop" button. This dialog is used by the following platforms :

Default text is : "Stop"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
text the stop action name to set.
Returns
  • the Camera instance

public Camera setStopActionText (int textResID)

Sets the text for the action "Stop" button. This dialog is used by the following platforms :

Default text is : "Stop"

This method should be called once before calling actions ( takePicture(CameraListener) or takeVideo(CameraListener))/

Parameters
textResID the resource id of the stop action name to set.
Returns
  • the Camera instance

public void takePicture (CameraListener callback)

Opens a dialog giving the user the choice to launch whether a picture gallery or a camera application to take a picture.
Once the picture was taken, it will be available in the application via the CameraListener parameter.

NB. the PHOTO_LIBRARY and CAMERA permissions need to be activated in the URS to use this method.

Cross Platform Considerations

  • In Android, if the picture is taken from the camera, it may be saved on the file system and available in the gallery depending on the default behavior of the application that takes the picture.

Parameters
callback camera listener to call after picture action.
Throws
NullPointerException if the callback parameter is null
MediaException if the method has been called with a device without camera feature
See Also

public void takePictureFromCamera (CameraListener callback)

Launches application chooser for the user to choose a camera application to take a picture.
Once the picture was taken, it will be available in the application via the CameraListener parameter.

NB. the CAMERA permission needs to be activated in the URS to use this method.

Cross Platform Considerations

  • In Android, the picture may be saved on the file system and available in the gallery depending on the default behavior of the application that takes the picture.

Parameters
callback camera listener to call after the picture has been taken.
Throws
NullPointerException if the callback parameter is null
MediaException if the method has been called with a device without camera feature

public void takePictureFromGallery (CameraListener callback)

Launches application chooser for the user to choose a gallery application to choose a picture.
Once the picture was chosen, it will be available in the application via the CameraListener parameter.

NB. the PHOTO_LIBRARY permission needs to be activated in the URS to use this method.

Parameters
callback camera listener to call after picture selection.
Throws
NullPointerException if the callback parameter is null

public void takeVideo (CameraListener callback)

Opens a dialog giving the user the choice to launch whether a picture gallery or a camera application to take a video.
Once the video was taken, it will be available in the application via the CameraListener parameter.

NB. the PHOTO_LIBRARY and CAMERA permissions need to be activated in the URS to use this method.

Cross Platform Considerations

  • In Android, if the video is taken from the camera, it may be saved on the file system and available in the gallery depending on the default behavior of the application that takes the video.

Parameters
callback camera listener to call after video action.
Throws
NullPointerException if the callback parameter is null
MediaException if the method has been called with a device without camera feature
See Also

public void takeVideoFromCamera (CameraListener callback)

Launches application chooser for the user to choose a camera application to take a video.
Once the video was taken, it will be available in the application via the CameraListener parameter.

NB. the CAMERA permission needs to be activated in the URS to use this method.

Cross Platform Considerations

  • In Android, the video may be saved on the file system and available in the gallery depending on the default behavior of the application that takes the video.

Parameters
callback camera listener to call after the video record.
Throws
NullPointerException if the callback parameter is null
MediaException if the method has been called with a device without camera feature

public void takeVideoFromGallery (CameraListener callback)

Launches application chooser for the user to choose a gallery application to choose a video.
Once the video was chosen, it will be available in the application via the CameraListener parameter.

NB. the PHOTO_LIBRARY permission needs to be activated in the URS to use this method.

Parameters
callback camera listener to call after video selection.
Throws
NullPointerException if the callback parameter is null