Intent based communication on Android (v2.0.x)

Overview

Beside the cmbSDK it is possible to communicate with MX-1000 and MX-1502 via Intents on Android devices. This page summarizes the different type of intents that can be used for interaction.

As MX Connect provides the connectivity between your Android device and MX mobile terminal, it is necessary that you install the latest MX Connect app on you device.

Introduction to Android intents and their usage is out of scope for this document.

Request Intents

The following broadcast intents can be used in apps to trigger some operation on mobile terminals via MXConnect.

Action String Parameter (name: type) Description
"com.cognex.mxconnect.action.START_SCANNING" Starts scanning on mobile terminal.
"com.cognex.mxconnect.action.STOP_SCANNING" Stops scanning on mobile terminal.
"com.cognex.mxconnect.query.DEVICE_TYPE"

Queries the device type of mobile terminal.

Returns "com.cognex.mxconnect.status.READER_NOT_AVAILABLE" if MX mobile terminal is not attached to the phone or it is sleeping.

"com.cognex.mxconnect.query.BATTERY_CHARGE" Queries the battery charge of mobile terminal.


The following activity intents can be used in apps to trigger some operation on mobile terminals via MXConnect.

Action String Parameter (name: type) Description
"com.cognex.mxconnect.action.FIRMWARE_UPGRADE"

uriString: String

Device's firmware is going to be upgraded with the file that was passed as parameter in uriString.

uriString: http/https:// or file:// address

verbose: int

Verbose parameter determines whether notifications should be shown during the process.

  • 1 - information in the status bar
  • 0 - no information
"com.cognex.mxconnect.action.CONFIG_UPLOAD" uriString: String

Device's configuration is going to be changed according to the file that was passed as parameter in uriString.

uriString: http/https:// or file:// address

verbose: int

Verbose parameter determines whether notifications should be shown during the process.

  • 1 - information in the status bar
  • 0 - no information

Response Intents

MX Connect is sending the following intents as response for some action (e.g. information was requested, availability of the device has been changed,etc.)

Action String Parameter (name: type) Description
"com.cognex.mxconnect.status.READER_NOT_AVAILABLE" Indicates that the reader device is not attached or disconnected.
"com.cognex.mxconnect.status.READER_AVAILABLE" Indicates that the reader is connected and ready.
"com.cognex.mxconnect.status.READER_LOCKED" Indicates that the reader device is exclusively used by an app. (e.g. QSA)
"com.cognex.mxconnect.action.MX_ATTACHED" Indicates that an MX reader was attached.
"com.cognex.mxconnect.action.MX_DETACHED" Indicates that an MX reader was detached.
"com.cognex.mxconnect.response.DEVICE_TYPE" value: String Response to request for device type intent. Type string is in the 'value' extra field.
"com.cognex.mxconnect.response.BATTERY_CHARGE" value: String Response to request for battery status intent. Current charge in percents is in the 'value' extra field.
"com.cognex.mxconnect.status.DOWNLOAD_PROGRESS" status:int Provides regular information about download progress during firmware upgrade or config upload.
"com.cognex.mxconnect.response.DOWNLOAD_ERROR" text: String Provides information about the failure that occurred during downloading firmware/config file.
"com.cognex.mxconnect.response.FILE_ERROR" text: String Provides information about the failure that occurred during opening firmware/config file.
"com.cognex.mxconnect.status.FIRMWARE_UPGRADE_STARTED" Indicates that MXConnect started the firmware upgrade operation on the device.
"com.cognex.mxconnect.status.FIRMWARE_UPGRADE_FAILED" text: String Provides information about the failure that occurred during firmware upgrade.
"com.cognex.mxconnect.status.CONFIG_UPLOAD_STARTED" Indicates that MXConnect started the config upload operation on the device.
"com.cognex.mxconnect.status.CONFIG_UPLOAD_FAILED" text: String Provides information about the failure that occurred during config upload.

Read Result Intent

Read result is sent with "com.cognex.mxconnect.action.READ_RESULT_RECEIVED" action string.

Parameters (Intent extras)

  • goodread: boolean
    Indicates whether result contains a successfully decoded barcode.
  • read_string: String (in case of good read)
    Decoded read string.
  • symbology: String (in case of good read)
    Decoded barcode's symbol type.
  • image: byte[] (in case of good read)
    Captured camera image.
    Only quarter sized JPEG byte data sent due to OS Intent limitations - the app sets this when connected.
  • imagegraphics: String (in case of good read)
    Contains SVG metadata.
  • xml: String
    Result(s) in XML form.