getPicture Function

The Camera.js file contains the getPicture function, which provides access to the device's default camera application for retrieving a picture asynchronously.

The getPicture function opens the device's default camera application (if the device has a camera) so the user can take a picture. Once the picture is taken, the device's camera application closes and the mobile workflow application is restored. If the device does not have a camera application, the functions reports that it is not supported.

Function Description
getPicture(onGetPictureError, onGetPictureSuccess, options)
  • onGetPictureError – If an error occurs with the picture chooser or the device camera, an appropriate error code is returned in the onGetPictureError function.
  • onGetPictureSuccess – the return value is sent to this function
  • options – picture options:
    • PictureOptions.CAMERA – the picture is stored in the camera application folder
    • PictureOptions.PHOTOLIBRARY – a native photo chooser dialog is shown, from which a photo from a file can be selected (JPEG only).
onGetPictureError(errorcode) This is a user defined function. Error codes include:
  • PictureError.NO_ERROR = 0;
  • /** getPicture() not implemented, camera not present, etc. */ PictureError.NOT_SUPPORTED = -1;
  • /** getPicture() has already been requested but has not yet completed. */PictureError.IN_PROGRESS = -2;
  • /** The user has canceled the request. */ PictureError.USER_REJECT = -3;
  • /** Supplied options were not recognized. */ PictureError.BAD_OPTIONS = -4;
  • /** The returned image size was too large to be handled by JavaScript */ PictureError.TOO_LARGE = -5;
  • /** An unknown error occurred. */ PictureError.UNKNOWN = -6;
onGetPictureSuccess(fileName, imageData) This is a user defined function. The return value is sent to the onGetPictureSuccess function, in one of the following formats, depending on the GetPicture options you specify. You can take this value and set it as a value into the MessageValueCollection function.
  • File name – file name of the image
  • imageData – Base64 encoded string representing the encoded picture (in JPEG format)

Example 1