The Brady Android SDK API
Templates
Template related objects include:
- TemplateFactory
- Template
- TemplateObjectData
- TemplateObjectType
TemplateFactory
The Brady SDK TemplateFactory is the only way for a user to get a Template object.
.getTemplate
Template TemplateFactory.getTemplate(InputStream template, Context context)
getTemplate returns a Template object.
- template: an InputStream object from the user-chosen template in their local directory. (See Example below).
InputStream iStream = getResources().openRawResource(getResources().getIdentifier(selectedFileName.split("[.]")[0], "raw", getPackageName()));
- context: a Context object that represents the UI Activity. (Example: MainActivity.this)
.getTemplate
Template TemplateFactory.getTemplate(String templateName, String resFolderName, Context context)
getTemplate returns a Template object.
-
templateName: a String representing the name of a template. Can be formatted as "ExampleTemplate.BWT" OR "ExampleTemplate".
-
resFolderName: a String representing the name of the directory that the template file resides in. If "ExampleTemplate.BWT" is within a folder called "raw" inside the "res" directory, you would pass in the value "raw".
-
context: a Context object that represents the UI Activity. (Example: MainActivity.this)
Template
- The Brady SDK Template object allows the user to:
- Retrieve a list of a .BWT file's data.
- Retrieve a Bitmap of the template used to preview the template in a UI.
- Retrieve the name of the .BWT file's label part.
.getTemplateData
TemplateObjectData[] getTemplateData();
getTemplateData returns a list of TemplateObjectData that the user may iterate through. This will hold information about the physical elements and objects on a Brady Workstation Template. (Reference TemplateObjectData)
.getPreview
Bitmap getPreview(int labelNumber, double dpi, double maxPixelWidthAndHeight, PrinterDetails printerDetails);
getPreview returns a Bitmap object of the chosen template. To set the Bitmap to our UI, we could then call something like:
ImageView.setImageBitmap(Template.getPreview(0, 96, Math.min(ImageView.getWidth(), ImageView.getHeight(), printerDetails));
-
labelNumber: an Integer that represents which label in the print job to get a preview of. (Currently we only support 1 print job at a time so this will always be 0).
-
dpi: a Double that represents the preview's "Dots Per Inch". This is usually 96 for most phones.
-
maxPixelWidthAndHeight: a Double that represents the dimension with the highest value. (See example above).
-
printerDetails: a PrinterDetails object that represents all information about the printer the mobile device is currently connected to. If null, the preview will not reflect an accurate print preview. If not null, the preview will reflect the color of the label supply and ribbon color.
.getSupplyName
String getSupplyName();
getSupplyName returns a String representing the name of the template's label part. In Brady Workstation, when we design a template, we always have to set a specific part. This could be useful information when validating a templates part or when comparing a connected printer's part.
.storeFonts
void storeFonts(Context context, int[] fontList);
Stores a list of resource ID's that represent font files that can be used later if a template was designed to use one of them.
Example: A template was designed with a text object whose font is "brady_fixed_width.ttf". This font file can be placed in an Android app's "res/font/" directory and then initialized like: "int[] fontList = new int[]{R.font.brady_fixed_width};"
- context is the Context of the current Activity
- fontList a list of int that represent font file resource ID's
TemplateObjectData
The Brady SDK TemplateObjectData object allows the user to retrieve an object on a Brady Workstation Template.
.getName
String getName();
getName gets a String representing the TemplateDataObject's set name.
.getValue
String getValue();
getValue gets a String representing the TemplateDataObject's set value.
.setValue
void setValue(String value);
setValue take's a String representing a new value that a user wants to set to the object. This is how a user may set the value of a Placeholder element on a Brady Workstation Template.
.getTemplateObjectType
TemplateObjectType getTemplateObjectType();
getTemplateObjectType gets a TemplateObjectType representing the type of object the instance is.
TemplateObjectType
TemplateObjectType is an enumeration that holds the types of objects on a Brady Workstation Template.
- StaticText: Text that cannot have it's value set by a user.
- Text: Text that was designed as a placeholder. Users can change the text's value with TemplateObjectData.setValue(newValue). DateTimeObjects are considered Text that can be set to anything (even text that isn't in date time format).
- Rectangle: A static rectangle that was drawn on the template.
- Barcode: Any Barcode object that was used to design the template. Barcodes can have human readable text attached to them as well. A change to the value will change both the human readable text and the barcode itself.
- Image: An image view that was placed on the template.
- PolyPolyLine: A type of static shape or line that was drawn on the template.
- Other: An type of object type that the SDK does not support yet.
Discovery
Discovery related objects include:
- PrinterDiscoveryFactory
- PrinterDiscovery
- PrinterDiscoveryListener
- DiscoveredPrinterInformation
- PrinterModel
- ConnectionType
PrinterDiscoveryFactory
The Brady SDK PrinterDiscoveryFactory is the only way for a user to get a PrinterDiscovery object
.getPrinterDiscovery
PrinterDiscovery PrinterDiscoveryFactory.getPrinterDiscovery(Context context, List[PrinterDiscoveryListener] listeners);
getPrintDiscovery returns a PrinterDiscovery object
- context: a Context object that represents the UI Activity. (Example: MainActivity.this)
- listeners: a List of PrinterDiscoveryListener objects that will listen for newly discovered printers and return them to the UI.
PrinterDiscovery
The Brady SDK PrinterDiscovery object allows the user to start discovery, stop discovery, and get information about discovered printers.
.startBluetoothPrinterDiscovery
void startBluetoothPrinterDiscovery(boolean showPairedPrintersOnly);
startBluetoothPrinterDiscovery starts discovering nearby bluetooth classic devices.
- showPairedPrintersOnly: A Boolean flag.
- If true, shows only printers that have been manually paired to the user's phone in their devices settings.
- If false, shows nearby devices in addition to any printers currently paired to the user's phone. (Will appear twice if both apply).
IMPORTANT NOTE: In May of 2023, Brady Corporation released a refresh of the M611 (named the Latimer) to support Bluetooth Low Energy instead of Bluetooth Classic. When connecting to a device discovered by this method, it should prompt the user to pair to it. If this pop-up does not appear and/or the user is unable to do so in the mobile device settings, the user's M611 is an M611 Latimer and can only connect via BLE. In this case, the "startBlePrinterDiscovery()" is the only method that should be used.
.startWifiPrinterDiscovery
void startWifiPrinterDiscovery();
startWifiPrinterDiscovery starts discovering nearby printers through the current wireless internet the user is connected to.
.startBlePrinterDiscovery
void startBlePrinterDiscovery() throws InvalidOperationException, InterruptedException;
startBlePrinterDiscovery starts discovering nearby printers through Bluetooth Low Energy.
.stopPrinterDiscovery
void stopPrinterDiscovery();
stopPrinterDiscovery stops any discovery scan that is currently running.
.getLastConnectedPrinter
DiscoveredPrinterInformation getLastConnectedPrinter();
getLastConnectedPrinter returns a DiscoveredPrinterInformation object that represents the printer that was successfully connected to most recently.
.forgetLastConnectedPrinter
void forgetLastConnectedPrinter();
forgetLastConnectedPrinter clears the internally stored printer. This printer will always be the one that was successfully connected to last. Calling this method will always result in getLastConnectedPrinter() returning null.
.connectToDiscoveredPrinter
PrinterDetails connectToDiscoveredPrinter(Context context, DiscoveredPrinterInformation printerSelected, List<PrinterUpdateListener> listeners);
connectToDiscoveredPrinter returns a PrinterDetails object holding all information about the connected printer and it's connection status.
- context: A Context object representing the UI context.
- printerSelected: A DiscoveredPrinterInformation object representing the printer that we are trying to connect to.
- listeners: A list of PrinterUpdateListener objects that will be notified if a change is made to a connected printer.
.connectWithManualIP
PrinterDetails connectWithManualIP(Context context, String ipAddress, PrinterModel printerModel, List<PrinterUpdateListener> listeners);
connectWithManualIP connects to a printer by specifying its IP address and model.
- context: A Context object representing the UI context.
- ipAddress: A string representing the IP address of the printer.
- printerModel: A PrinterModel enum representing the model of the printer.
- listeners: A list of PrinterUpdateListener objects that will be notified if a change is made to a connected printer.
- Returns: A PrinterDetails object if successful and null if unsuccessful. This holds all information about the connected printer.
.getHaveOwnership
Boolean getHaveOwnership();
getHaveOwnership returns a boolean representing the ownership the device has to the Bluetooth Low Energy printer. Ownership is a concept on the M211 only. Depending on the result that is returned, you might want to display messages to the user in the form of a Toast or Snackbar.
IF TRUE: Your device has claimed ownership of the printer. This means no other mobile device can connect to the printer. The blue Bluetooth light on the printer goes solid when somebody has ownership. You may hold the power button for 5 seconds to release ownership. However, just because the blue light is solid DOES NOT mean you are currently connected. These are two completely separate things. The only way they relate is that you must attempt to connect at least once to claim ownership. Even if this connection fails, you might still gain ownership successfully.
IF FALSE: You attempted to claim ownership at one point and were rejected because somebody else already as ownership. This doesn't necessarily have to be another device. With the same phone, if you connect to an M211 in the Brady Express Labels app, close the app to disconnect, open your app using the SDK, and attempt to connect, you will be rejected ownership.
IF NULL: The ownership of the desired printer is unknown because your device has not successfully "made contact" with the printer yet. This might be due to a ConnectionTimeout error or some other unrelated error that cause the connection to exit early.
onResume()
onResume is a lifecycle method that should be placed in the onResume() of the class PrinterDiscovery is being used in. This triggers when the activity resumes.
onPause()
onPause is a lifecycle method that should be placed in the onPause() of the class PrinterDiscovery is being used in. This triggers when the activity pauses (is set to the background).
onDestroy()
onDestroy is a lifecycle method that should be placed in the onDestroy() of the class PrinterDiscovery is being used in. This triggers when the activity is destroyed.
PrinterDiscoveryListener
PrinterDiscoveryListener is implemented by a user in a UI class to catch when new printers are discovered. The class that implements PrinterDiscoveryListener can also start and stop printer discovery.
.printerDiscovered
void printerDiscovered(DiscoveredPrinterInformation discoveredPrinterInformation);
printerDiscovered triggers when a user implements this interface into their front end and a printer is discovered.
- discoveredPrinterInformation: the printer information that is discovered.
.printerRemoved
void printerRemoved(DiscoveredPrinterInformation discoveredPrinterInformation);
printerRemoved triggers when a BLE printer has not been seen for 10 seconds. This method only applies to Bluetooth Low Energy scans.
- discoveredPrinterInformation: the printer information that is discovered.
.printerDiscoveryStarted
void printerDiscoveryStarted();
printerDiscoveryStarted triggers automatically when a discovery scan is started in the SDK's code.
.printerDiscoveryStopped
void printerDiscoveryStopped(); printerDiscoveryStopped triggers automatically when a discovery scan is stopped in the SDK's code.
PrinterModel
PrinterModel is an enumeration that represents all SDK supported printer models.
- M611: M611 Printer
- M211: M211 Printer
- M511: M511 Printer
- M610: M610 Printer
- BMP61: BMP61 Printer
- BMP51: BMP51 Printer
- M710: M710 Printer
- S3700: S3700 Printer
- i5300: i5300 Printer
- i7500: i7500 Printer
- i3311: i3311 Printer
- i4311: i4311 Printer
- i5311: i5311 Printer
- M811J: M811J Printer
DiscoveredPrinterInformation
The Brady SDK DiscoveredPrinterInformation object is returned when a nearby printer is discovered. It only allows the user to get the printer's name because the SDK handles everything else related to the printer's discovery.
.getName
String getName();
getName returns a String that represents the discovered printer's name. This is later used to connect to the same printer.
.getModel
String getModel();
getModel returns a String that represents the discovered printer's model name.
.getConnectionType
ConnectionType getConnectionType();
getConnectionType returns the enumeration ConnectionType representing how the discovered printer was discovered (Bluetooth, Wi-Fi, or BLE).
Connection
Connection related objects include:
- PrinterDetails
- PrinterUpdateListener
- PrinterProperties
- PrinterStatus
- PrintMode
- MaintenanceStation
- PrintingOptions
- PrintingStatus
- CutOption
- PostPrintAccessoryType
PrinterDetails
The Brady SDK PrinterDetails object is returned after connecting to a printer. It holds all of the information about the printer that the user may need.
.reconnect
boolean reconnect();
reconnect allows the user to reconnect to a recently disconnected printer. T his should only be used when there was a previous system disconnect (one that was not initiated by the user calling disconnect() explicitly).
NOTE: A reconnection will only be successful when called after disconnectWithoutForget(). This is because disconnect() forgets the printer so there will be nothing to reconnect to.
.disconnect
void disconnect();
disconnect allows the user to disconnect from the connected printer.
.disconnectWithoutForget
void disconnectWithoutForget();
disconnectWithoutForget disconnects from the current printer without forgetting it internally allowing future auto-connects. Calling this immediately before PrinterDetails.forgetLastConnectedPrinter() will result in the same functionality as calling the normal "disconnect" method. Therefore, disconnectWithoutForget + forgetLastConnectedPrinter = disconnect.
.print (Templates)
PrintingStatus print(Context context, Template template, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print a selected template to the connected printer using PrintingOptions to do so. returns a PrintingStatus object.
- context: A Context object that represents a UI context
- template: The Template object that we want to print.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: A Boolean flag. Input "null" if not an M211.
- If true, don't print a trailer on the end of a label during the print.
- If false, print a trailer on the end of a label during the print.
.print (Single Bitmap)
PrintingStatus print(Context context, Bitmap bitmap, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print an image in the form of a bitmap to the connected printer using PrintingOptions to do so. Images supported include PNG, JPG, JPEG, WEBP, and SVG. The image always maintains its original aspect ratio and will be resized to fill the dimension of the first printable zone of the installed supply. Returns a PrintingStatus object.
- context: A Context object that represents a UI context
- bitmap: the image that we want to print.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: A Boolean flag. Input "null" if not an M211.
- If true, don't print a trailer on the end of a label during the print.
- If false, print a trailer on the end of a label during the print.
.print (Single Bitmap w/ Offset)
PrintingStatus print(Context context, Bitmap bitmap, Double bitmapWidth, Double labelLength, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to instead specify the width of the image and the length of the label in inches in order to print an image. The purpose of this method is to allow a user to resize how the image appears on the label if they are unhappy with the defaulted outcome. Returns the PrintingStatus when finished.
For example: This method is useful if the desired image to print is not square. Since the physical supply width cannot change, increasing the labelLength value might begin to eliminate wasted space on a label since the image will have more room to grow to fit. Vice versa, if the image does not entirely fit on a label, you may decrease the imageWidth value to shrink the image to fit on the label fully.
- context: A Context object that represents a UI context
- bitmap: the image that we want to print.
- bitmapWidth: allows the user to customize the width (in inches) of the image once it prints instead of using the default.
- labelLength: allows the user to customize the length (in inches) of the label instead of using the default. Currently, M611 continuous parts have a length of 0.5 inches before being overrided according to the information we receive from the printer. The width (in inches) will always be stated on the physical part.
- printingOptions: the PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: If true, don't print trailer white space after the printed label. If false, print one.
.print (Multiple Bitmaps)
PrintingStatus print(Context context, List<Bitmap> bitmaps, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print multiple images in the form of bitmaps to the connected printer using PrintingOptions to do so. Images supported include PNG, JPG, JPEG, WEBP, and SVG. The images always maintain their original aspect ratio and will be resized to fill the dimension of the first printable zone of the installed supply. Returns a PrintingStatus object.
- context: A Context object that represents a UI context
- bitmaps: the list of images that we want to print.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: A Boolean flag. Input "null" if not an M211.
- If true, don't print a trailer on the end of a label during the print.
- If false, print a trailer on the end of a label during the print.
.print (Multiple Bitmaps w/ Offset)
PrintingStatus print(Context context, List<Bitmap> bitmaps, Double bitmapWidth, Double labelLength, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to instead specify the width of the image and the length of the label in inches in order to print an image. The purpose of this method is to allow a user to resize how the image appears on the label if they are unhappy with the defaulted outcome. Returns the PrintingStatus when finished.
For example: This method is useful if the desired image to print is not square. Since the physical supply width cannot change, increasing the labelLength value might begin to eliminate wasted space on a label since the image will have more room to grow to fit. Vice versa, if the image does not entirely fit on a label, you may decrease the imageWidth value to shrink the image to fit on the label fully.
- context: A Context object that represents a UI context
- bitmaps: the list of images that we want to print.
- bitmapWidth: allows the user to customize the width (in inches) of the image once it prints instead of using the default.
- labelLength: allows the user to customize the length (in inches) of the label instead of using the default. Currently, M611 continuous parts have a length of 0.5 inches before being overrided according to the information we receive from the printer. The width (in inches) will always be stated on the physical part.
- printingOptions: the PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: If true, don't print trailer white space after the printed label. If false, print one.
.print (Templates with RFID)
PrintingStatus print(Context context, Template template, RfidOperation[][] rfidOperations, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print a selected template with RFID operations to the connected printer using PrintingOptions to do so. returns a PrintingStatus object.
- context: A Context object that represents a UI context
- template: The Template object that we want to print.
- rfidOperations: A 2D array of RfidOperation objects representing the RFID operations for each page.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: A Boolean flag. Input "null" if not an M211.
- If true, don't print a trailer on the end of a label during the print.
- If false, print a trailer on the end of a label during the print.
.print (Single Bitmap with RFID)
PrintingStatus print(Context context, Bitmap bitmap, RfidOperation[][] rfidOperations, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print an image with RFID operations from the connected printer using PrintingOptions to do so. Returns a PrintingStatus object.
- context: A Context object that represents a UI context
- bitmap: the image that we want to print.
- rfidOperations: A 2D array of RfidOperation objects representing the RFID operations for each page.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: A Boolean flag. Input "null" if not an M211.
- If true, don't print a trailer on the end of a label during the print.
- If false, print a trailer on the end of a label during the print.
.print (Multiple Bitmaps with RFID)
PrintingStatus print(Context context, List<Bitmap> bitmaps, RfidOperation[][] rfidOperations, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print a list of images with RFID operations from the connected printer using PrintingOptions to do so. Returns a PrintingStatus object.
- context: A Context object that represents a UI context
- bitmaps: a list of images that will be printed.
- rfidOperations: A 2D array of RfidOperation objects representing the RFID operations for each page.
- printingOptions: The PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: If true, don't print trailer white space after the printed label. If false, print one.
Example: The code below will encode 1AAAAAAAAAA to the first label, 2BBBBBBBBBB to the second label, and 3CCCCCCCCCC to the third label along with their respective images:
RfidOperation[][] rfidOperations = new RfidOperation[][] {
{
new RfidOperation(RfidCommandType.Write, RfidInputType.Ascii, RfidLocation.ElectronicProductCode, "1AAAAAAAAAA", null, 0, null, null),
new RfidOperation(RfidCommandType.Write, RfidInputType.Hex, RfidLocation.User, "AAAAAAAAAA", null, 0, null, null)
},
{
new RfidOperation(RfidCommandType.Write, RfidInputType.Ascii, RfidLocation.ElectronicProductCode, "2BBBBBBBBBB", null, 0, null, null),
new RfidOperation(RfidCommandType.Write, RfidInputType.Hex, RfidLocation.User, "BBBBBBBBBB", null, 0, null, null)
},
{
new RfidOperation(RfidCommandType.Write, RfidInputType.Ascii, RfidLocation.ElectronicProductCode, "3CCCCCCCCCC", null, 0, null, null),
new RfidOperation(RfidCommandType.Write, RfidInputType.Hex, RfidLocation.User, "CCCCCCCCCC", null, 0, null, null)
}
};
PrintingStatus printingStatus = printerDetails.print(context, bitmap, rfidOperations, printingOptions, false);
.print (Multiple Bitmaps with Offset and RFID)
PrintingStatus print(Context context, List<Bitmap> bitmaps, RfidOperation[][] rfidOperations, Double bitmapWidth, Double labelLength, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag);
print allows the user to print a list of images with RFID operations while specifying the width and length of the label in inches. Returns the PrintingStatus when finished.
- context: A Context object that represents a UI context
- bitmaps: a list of images that will be printed.
- rfidOperations: A 2D array of RfidOperation objects representing the RFID operations for each page.
- bitmapWidth: allows the user to customize the width (in inches) of the image once it prints instead of using the default.
- labelLength: allows the user to customize the length (in inches) of the label instead of using the default.
- printingOptions: the PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: If true, don't print trailer white space after the printed label. If false, print one.
.printPDF
PrintingStatus printPDF(Context context, byte[] pdfData, int rotationDegrees, PrintingOptions printingOptions, Boolean dontPrintTrailerFlag) throws IOException
print allows the user to print a PDF from the connected printer using PrintingOptions to do so. By default, the PDF page will be scaled to fit the installed supply. If the installed supply in the printer is a continuous supply, the label length will be adjusted to match the PDF's aspect ratio. If the installed supply is pre-sized, the PDF will be scaled to fit inside the first printable area.
- context: the context of the front end that is calling this method.
- pdfData: a byte array representing a PDF file's data.
- rotationDegrees: the degrees to rotate the PDF page content before printing (0, 90, 180, 270).
- printingOptions: the PrintingOptions object that holds the information of how to print.
- dontPrintTrailerFlag: If true, don't print trailer white space after the printed label. If false, print one.
Returns PrintingStatus enumeration that represents the printing result after it has finished. Throws IOException if there is an error reading the PDF file from the provided path.
.checkForSupplyMismatch
boolean checkForSupplyMismatch(Template template);
checkForSupplyMismatch compares the part in the connected printer to the part used to create the template. Returns true if the parts match, false if they are different.
- template: The template object to compare.
.getPrinterStatus
PrinterStatus getPrinterStatus();
getPrinterStatus returns the PrinterStatus enumeration that describes the state of the printer's connection.
.getPrinterName
String getPrinterName();
getPrinterName returns a String that represents the name of the connected printer.
.getPrinterModel
String getPrinterModel();
getPrinterModel returns a String that represents the model of the connected printer.
.getConnectionType
ConnectionType getConnectionType();
getConnectionType returns the ConnectionType enumeration that describes how we are connected to the printer.
.getBatteryLevelPercentage
Integer getBatteryLevelPercentage();
getBatteryLevelPercentage returns an Integer that represents roughly the battery life percentage of the printer.
.getIsAcConnected
boolean getIsAcConnected();
getIsAcConnected returns a Boolean that represents whether this printer is plugged into an outlet and on AC power.
.getPrinterStatusMessage
String getPrinterStatusMessage();
getPrinterStatusMessage returns a String that represents the body of a printer error message.
.getPrinterStatusRemedyExplanationMessage
String getPrinterStatusRemedyExplanationMessage();
getPrinterStatusRemedyExplanationMessage returns a String that represents the remedy to a printer error.
.getPrinterStatusMessageTitle
String getPrinterStatusMessageTitle();
getPrinterStatusMessageTitle returns a String that represents the title of the printer error.
.getSupplyName
String getSupplyName();
getSupplyName returns a String that represents the full name of the part loaded in the connected printer.
.getSupplyColor
Color getSupplyColor();
getSupplyColor returns a Color that represents the physical color of the label (supply tape) installed in the connected printer. This will be the background color of the printed out label.
.getSupplyRemainingPercentage
Integer getSupplyRemainingPercentage();
getSupplyRemainingPercentage returns an Integer that represents the percentage of remaining supply in the connected printer.
.getSupplyDimensions
String getSupplyDimensions();
getSupplyDimensions returns a String that represents the supply dimensions (width and height).
.getSupplyWidth
double getSupplyWidth();
getSupplyWidth returns a Double that represents the width of the connected printer's supply in inches (will return 0 if the connected printer is not applicable).
.getSupplyHeight
double getSupplyHeight();
getSupplyHeight returns a Double that represents the height of the connected printer's supply in inches (will return 0 if the connected printer is not applicable).
.getSupplyLeftOffset
double getSupplyLeftOffset();
getSupplyLeftOffset returns a Double that represents the left offset of the connected printer's supply in inches (will return 0 if the connected printer is not applicable).
.getSupplyVerticalOffset
double getSupplyVerticalOffset();
getSupplyLeftOffset returns a Double that represents the vertical offset of the connected printer's supply in inches (will return 0 if the connected printer is not applicable).
.isSupplyValid
boolean isSupplyValid();
isSupplyValid returns a Boolean that represents if the installed supply is a valid supply.
.getIsSupplyPreSized
Boolean getIsSupplyPreSized();
getIsSupplyPreSized returns a Boolean that represents if the installed supply in the connected printer is a pre-sized supply. If false, the supply could be continuous or another supply not categorized as die-cut.
.getYNumber
String getYNumber();
getYNumber returns a String that represents the supply unique identifier
.getRibbonName
String getRibbonName();
getRibbonName returns a String that represents the name of the ribbon loaded in the printer (will return an empty string if the connected printer not applicable).
.getRibbonRemainingPercentage
Integer getRibbonRemainingPercentage();
getRibbonRemainingPercentage returns an Integer that represents the amount of ribbon remaining as a percentage (will return 0 if the connected printer is not applicable).
.getRibbonColor
Color getRibbonColor();
getRibbonColor returns a Color that represents the physical color of the Ribbon installed in the connected printer. This will be the color of everything printed on the label.
.isRibbonValid
boolean isRibbonValid();
isRibbonValid returns a boolean that represents if the installed ribbon in the connected printer is valid.
.cutSupply
void cutSupply();
cutSupply sends the cut printer operation to the printer to cut a label.
.feedSupply
void feedSupply();
feedSupply sends the feed operation to the printer to feed a label.
.getAutomaticShutdownTime
**int getAutomaticShutdownTime();
getAutomaticShutdownTime returns an Integer of the automatic shutdown time of the connected printer in minutes. Only applicable to the M211 and M511.
.setAutomaticShutdownTime
void setAutomaticShutdownTime(int timeInMinutes);
setAutomaticShutdownTime sets the automatic shutdown time of the printer in minutes. This is only functional when connected to an M211, M511, or inkjet printer. This will set the setting on the printer that controls when it automatically shuts off. This timer will only begin when no devices are connected to the printer. The printers should never turn off automatically when in use.
- timeInMinutes: An Integer that represents the amount of minutes it takes for the connected printer to shut down automatically. Using the value of 0 will:
- M811J: Will cause the printer to never shut down.
- M211 & M511: Will throw an exception because this value is not supported by the firmware.
.getPostPrintAccessoryType
PostPrintAccessoryType getPostPrintAccessoryType();
getPostPrintAccessoryType returns a PostPrintAccessoryType that represents the name of the installed post print accessory. This is currently only supported on the i7500 printer. The default value will be "None" while connected to any other printer model.
.getDotsPerInch
int getDotsPerInch();
getDotsPerInch returns an integer that represents the dots per inch capability of the connected printer.
.isDirectThermalSupply
boolean isDirectThermalSupply();
isDirectThermalSupply returns a boolean that represents if the connected printer has a direct thermal supply installed.
.isPreprintedSupply
boolean isPreprintedSupply();
isPreprintedSupply returns a boolean that represents if the connected printer has a supply with a preprinted graphic.
.getFirmwareVersion
String getFirmwareVersion();
getFirmwareVersion returns the String of the connected printer's firmware version
.getLabelLibraryVersion
String getLabelLibraryVersion();
getLabelLibraryVersion returns a String of the connected printer's label library (YB file) version
.getErrorSeverity
**String getErrorSeverity();
getErrorSeverity returns a String of the connected printer's error severity. For the M211 and M511, this will always be an empty string. Use the Printer Status instead.
.getInkRemainingPercentage
Integer getInkRemainingPercentage();
getInkRemainingPercentage returns an Integer that represents the amount of ink remaining as a percentage (0 - 100).
.getBluetoothVersion
String getBluetoothVersion();
getBluetoothVersion returns the String of the connected printer's Bluetooth version. This is only applicable to M610 and M710 printers.
.getWifiVersion
String getWifiVersion();
getWifiVersion returns the String of the connected printer's Wifi version. This is only applicable to M610 and M710 printers.
.getOutOfInkCmy
boolean getOutOfInkCmy();
getOutOfInkCmy returns true if the printer is out of CMY ink.
.getIsCleanPrintheadMaintenanceRecommended
boolean getIsCleanPrintheadMaintenanceRecommended();
getIsCleanPrintheadMaintenanceRecommended returns true if clean printhead maintenance is recommended.
.getCleanPrintheadSuccessful
boolean getCleanPrintheadSuccessful();
getCleanPrintheadSuccessful returns true if the clean printhead maintenance was successful.
.cleanPrinthead
boolean cleanPrinthead();
cleanPrinthead sends a clean printhead command to the printer. This command is fire-and-forget and operates asynchronously. It returns true immediately upon successfully sending the command to the printer. The SDK will monitor the printer in the background and automatically print a test label once the cleaning cycle physically completes.
.getMaintenanceStationWarningAway
boolean getMaintenanceStationWarningAway();
getMaintenanceStationWarningAway returns true if the maintenance station warning away is triggered.
.getMaintenanceStationErrorAway
boolean getMaintenanceStationErrorAway();
getMaintenanceStationErrorAway returns true if the maintenance station is at the away position and a maintenance reminder is triggered.
.setMaintenanceStationProperty
boolean setMaintenanceStationProperty(MaintenanceStation station);
setMaintenanceStationProperty sends a command to set the maintenance station property. The printer will notify the SDK via the message, getPrinterStatusMessage(), getPrinterStatusMessageTitle(), and getPrinterStatusRemedyExplanationMessage() properties when the maintenance station needs to be replaced. If this is the case, users may call this method and pass in MaintenanceStation.Reset to tell the printer you've successfully replaced the maintenance station physically. This will resolve the printer error. Users may also pass in MaintenanceStation.RemindMeLater to dismiss the printer error and to be notified at a later date. From a UI point of view, these two options could be handled via a pop-up window with an "Ask Me Later" and a "Done" button, for example.
- station: The desired maintenance station setting as a MaintenanceStation enum (either Reset or RemindMeLater).
- Returns: true if the command was successfully sent to the printer.
.getAvailablePrintQualityModes
String[] getAvailablePrintQualityModes();
getAvailablePrintQualityModes returns an array of strings representing the available print quality modes of the printer.
.getValidInkSupply
boolean getValidInkSupply();
getValidInkSupply returns true if the ink supply is valid.
.getPrintheadInstalled
boolean getPrintheadInstalled();
getPrintheadInstalled returns true if the printhead is installed.
.printAlignmentLabel
boolean printAlignmentLabel();
printAlignmentLabel sends a command to print the printer alignment label. This command can be sent to the printer to print out the premade alignment label. Once printed out, this label provides a visual to help the user calibrate the alignment of the printer. This should be used if the user notices inaccuracies when printing fine lines such as photographs. The actual calibration process can be completed using the setAlignmentOffset method.
- Returns: true if the command was successfully sent to the printer.
.getAlignmentOffset
int getAlignmentOffset();
getAlignmentOffset returns the alignment offset of the printer.
.setAlignmentOffset
boolean setAlignmentOffset(int offsetValue);
setAlignmentOffset sends a command to set the alignment offset and controls the calibration of the printer alignment. The number that should be passed in as a parameter must be between -7 and 7 and should match wherever the pink line is most solid after observing the print-out that printAlignmentLabel() produced.
For example: If the user called printAlignmentLabel() and the physical label shows a pink line that is the most solid at -4 on the chart, then the number -4 should be passed into this setAlignmentOffset method. This should result in the pink line being most solid at 0 the next time printAlignmentLabel() is called.
- offsetValue: The alignment offset value to set (must be between -7 and 7).
- Returns: true if the command was successfully sent to the printer.
.setPrinterQualityMode
void setPrinterQualityMode(PrintMode printMode);
setPrinterQualityMode sets the quality mode of all future print jobs. These different modes show clear differences in the sharpness and saturation of colored printing. Users should use the getAvailablePrintQualityModes() method to retrieve all available options to use for this parameter. Passing in null will use the PrintMode.Default setting.
- printMode: The desired quality mode as a PrintMode enum.
PrinterUpdateListener
The Brady SDK PrinterUpdateListener interface can be implemented to an Activity.
PrinterUpdate
void PrinterUpdate(List<PrinterProperties> changedProperties);
PrinterUpdate triggers whenever a PrinterProperty changes on the current printer connection.
For example, if a user changes the part installed in the printer, this function will trigger and "changedProperties" will contain "SupplyName", "SupplyYNumber", "SupplyHeight", "SupplyWidth", and "SubstrateRemainingPercent" (assuming the new part isn't the same in dimension).
- This interface can be implemented to an Activity by adding implements PrinterUpdateListener in the class header.
- The PrinterUpdate function is required to be implemented when this is done (even if you leave the function empty).
PrinterProperties
PrinterProperties is an enumeration that represents different properties that describe the connected printer. This can be used to check which components are changed when implementing the PrinterUpdateListener.
- JobsInQueue: property representing the amount of print jobs in queue.
- RibbonPartNumber: property prepresenting the connected printer's ribbon part number.
- RibbonColor: property representing the connected printer's ribbon color.
- RibbonRemainingPercent: property representing the percentage remaining of the connected printer's ribbon.
- RibbonIsInvalid: property representing the validity of the connected printer's ribbon.
- SupplyName: property representing the name of the connected printer's supply part.
- SupplyYNumber: property representing the Y Number of the current part installed in the connected printer.
- SupplyWidth: property representing the width of the current supply installed in the connected printer.
- SupplyHeight: property representing the height of the current supply installed in the connected printer.
- SupplyRemainingPercent: property representing the percentage remaining of the connected printer's supply.
- SupplyIsTearoff: property representing if the connected printer's installed supply is tearoff or not.
- SupplyIsPreSized: If the connected printer's installed part is pre-sized.
- SupplyLeftOffset: The left offset of the part currently installed in the connected printer.
- SupplyVerticalOffset: The vertical offset of the part currently installed in the connected printer.
- SupplyColor: The color of the supply installed in the connected printer.
- SupplyInvalid: Is the supply installed in the connected printer is valid or not.
- SupplyIsDirectThermal: Is the supply installed in the connected printer direct thermal or not.
- SupplyIsPreprinted: If the connected printer's installed supply includes a preprinted graphic.
- PostPrintAccessoryType: The hardware accessory installed on the printer for post-printing actions.
- DotsPerInch: The dots per inch capabilities of the connected printer.
- Message: property representing the message body of a printer error.
- RemedyExplanationMessage: property representing the remedy explanation of a printer error.
- MessageTitle: property representing the message title of a printer error.
- CurrentStatus: property representing the current status of the connected printer.
- FirmwareVersion: property representing the firmware version number of the connected printer.
- AcConnected: property representing if the connected printer is plugged into an AC power source.
- BatteryChargePercentage: property representing the percentage of battery left in the connected printer.
- TotalJobsQueued: property representing the amount of jobs queued to print on the connected printer.
- AllJobsGroup: property representing the print jobs on the connected printer as a whole.
- AutoShutoffTime: property representing the time in minutes that it takes the connected printer to shut off automatically.
- BluetoothVersion: The Bluetooth version of the connected printer (only applicable to M610 & M710).
- WifiVersion: The Wi-Fi version of the connected printer (only applicable to M610 & M710).
- LabelLibraryVersion: The Label Library (YB file) Version of the connected printer's firmware.
- ErrorSeverity: The Error Severity of the connected printer.
- ValidSupply: The validity of the connected printer's installed supply.
- ValidRibbon: The validity of the connected printer's installed ribbon.
- SupplyColumnCount: The number of columns across on the installed supply.
- SupplyHorizontalGap: The horizontal gap between labels on the installed supply.
- SupplyVerticalGap: The vertical gap between labels on the installed supply.
PrinterStatus
PrinterStatus is an enumeration that represents values of the printer's connection status.
- NoPrinter: status for when no printer is found when trying to find the printer's status.
- Disconnected: status for when the printer is disconnected and no longer monitoring.
- Connecting: status for when the printer is currently attempting to connect to the user's mobile device.
- Connected: status for when the printer is connected to a user's mobile device and monitoring.
- Warning: status for when the printer is in a warning state where an error could potentially occur.
- Error: status for when the printer has an error while connected to the user's mobile device.
PrintMode
PrintMode is an enumeration that defines the available print quality modes that can be set for a print job.
- Draft: Draft mode prioritizes print speed over high resolution quality.
- Precision: Precision mode balances speed and quality for clear, precise text and barcodes.
- Photo: Photo mode prioritizes highest resolution quality, optimal for printing images.
- Default: Default mode uses the printer's current default quality setting.
MaintenanceStation
MaintenanceStation is an enumeration that defines the available options for interacting with the printer's maintenance station (spittoon) reminder. This is used to clear or postpone maintenance warnings.
- Reset: Indicates that the maintenance has been completed. This resets the maintenance counter and clears the reminder.
- RemindMeLater: Indicates that the maintenance reminder should be temporarily dismissed and trigger again later.
ConnectionType
ConnectionType is an enumeration that represents how a given printer was discovered. In turn, this would also be the protocol used to connect to the same printer.
-
Bluetooth: Represents a printer that was discovered using Bluetooth Classic.
-
Wifi: Represents a printer that was discovered over Wifi or Wireless Internet.
-
BLE: Represents a printer that was discovered using Bluetooth Low Energy.
Printing
Objects related to printing are:
- PrintingStatus
- PrintingOptions
- CutOption
- PostPrintAccessoryType
PrintingStatus
PrintingStatus is an enumeration that consists of values that represent the print job status.
- Unknown: represents the status not being able to be recognized.
- Printing: status that represents the currently ongoing printing operation.
- PrintingSucceeded: status that represents a successful print job after it completes.
- PrintingFailed: status that represents a failed print job after the attempt to print.
PrintingOptions
The Brady SDK PrintingOptions class is required to be initalized as an object when calling the ".print" method in PrinterDetails. This holds the information that the printer needs to complete a print job.
.getCutOption
CutOption getCutOption();
getCutOption returns a CutOption enumeration value. The default is "EndOfLabel".
.setCutOption
void setCutOption(CutOption cutOption);
setCutOption allows the user to change the value of the cut option.
.getNumberOfCopies
int getNumberOfCopies();
getNumberOfCopies returns the number of copies the user wants to print. The default is 1.
.setNumberOfCopies
void setNumberOfCopies(int numberOfCopies);
setNumberOfCopies allows the user to set the number of copies they want to print.
.getIsCollated
boolean getIsCollated();
getIsCollated returns a boolean representing if the desired print job should be collated.
Collated Example: If a single template has 2 different labels designed for it, the collated option becomes available to use. If we are trying to print 2 copies of both labels, the collated version prints them in the order of 1,2,1,2. Alternatively, if the collated flag is set to false, it will print the labels in the order of "1,1,2,2".
.setIsCollated
void setIsCollated(boolean collated);
setIsCollated allows the user to specify if the next print jobs will printed as collated or not collated.
.getCutAfterRowValue
int getCutAfterRowValue()
getCutAfterRowValue returns an integer that represents how many rows of labels to print before cutting each time.
.setCutAfterRowValue
void setCutAfterRowValue(int cutAfterRowValue);
setCutAfterRowValue allows the user to specify how many rows of labels to print before cutting each time. For example, "setCutAfterRowValue(2)" will tell the printer to cut after every 2 rows of labels. This option is only supported on the M611, S3700, and i7500 printers. Print will not be successful when used with an unsupported printer.
CutOptions
The Brady SDK CutOptions object is an enumeration that represents when to perform a cut operation during the print job.
- EndOfJob: Performs a cut at the end of the entire print job.
- EndOfLabel: Performs a cut at the end of each label.
- Never: Never performs a cut operation throughout the print.
- CutAfterRow: Performs a cut at the end of a specified row of labels.
- This cut option is only supported on the M611, S3700, i5300, and i7500 printers. An SdkApiException will be thrown if used with an unsupported printer.
- Must be used with the "PrintingOptions.cutAfterRowValue" method. For example, "printingOptions.setCutAfterRowValue(2)" will tell the printer to cut after every 2 labels.
- UsePrinterSettings: Uses the printer settings configured on the printer to determine when to perform a cut. This cut option is only supported on the i7500 printer. An SdkException will be thrown if used with an unsupported printer.
PostPrintAccessoryType
The Brady SDK PostPrintAccessoryType object is an enumeration that represents the name of the post print accessory installed on the connected printer.
- TearBar: A TearBar is a jagged-edged attachment that allows a user to tear a label after it prints.
- AutoCutter: An AutoCutter is an attachment that allows a user to automatically cut a label after it printsbased on the CutOption that is sent in the print job. The CutOption "UsePrinterSetting" will tell the printer to use the cut option that is set on the printer.
- PeelWithoutLabelTakenSensor: The base Peeler attachment. Currently, the SDK does not support control over this setting. If this is installed on the printer, the CutOption will be defaulted to "UsePrinterSettings".
- PeelWithLabelTakenSensor: A Peeler attachment that can sense when a label has been taken. Currently, the SDK does not support control over this setting. If this is installed on the printer, the CutOption will be defaulted to "UsePrinterSettings".
- PerforationCutter: A PerforationCutter attachment that can cut a separator for easy tear off after print. Currently, the SDK does not support control over this setting. If this is installed on the printer, the CutOption will be defaulted to "UsePrinterSettings".
- None: No post print accessory is installed on the printer. None will also be the default value for printers that do not support post print accessories.
Exceptions
The SDK provides the user a list of exceptions that they may use when calling any of the API's methods. This can come in handy when catching errors that will provide more details that are specific to the Brady SDK.
SdkApiException
This is the base exception that will be extended by more specific exceptions (all listed below). Users are encouraged to catch only this base exception since this will successfully catch all other custom exceptions.
PrinterDiscoveryException
Thrown when an error occurs related to printer discovery.
PrinterConnectionException
Thrown when an error occurs related to printer connection.
TemplateNotLoadedException
Thown when an error occurs when attempting to load a template.
InvalidPlaceholderDataException
Thrown when an error is caused by invalid data being set to a template placeholder.
TemplateRenderingException
Thrown when an error occurs while attempting to render template objects during getPreview() or the print() methods.
PrinterOperationException
Thrown when an error occurs while attempting a printer operation such as feed, cut, of setAutomaticShutdownTime.
PrintingException
Thrown when an error occurs at print time.
DisconnectionException
Thrown when an error occurs while attempting to disconnect from a printer.
UnsupportedPrinterException
Thrown when an error related to an incompatibility issue between the SDK and the connected printer occurs. The SDK might not support this printer.
RFID
RFID related objects include:
- RfidOperation
- RfidCommandType
- RfidLocation
- RfidInputType
RfidOperation
The Brady SDK RfidOperation class represents an RFID operation to be performed on a printer. The only mandatory property is the 'command'. All other properties are optional.
Constructor
RfidOperation(RfidCommandType command, RfidInputType inputType, RfidLocation location, String data, Long password, Integer offset, Integer numberOfBlocks, Integer value) throws SdkApiException
Creates an RfidOperation with all properties. Only 'command' is required; all other parameters can be null.
- command: The RFID command to execute (Required).
- inputType: The type of input data (ASCII or HEX) (Required).
- location: The memory location for the operation (Optional).
- data: The data to be written or used in the operation (Optional).
- password: The access password for protected memory banks (Optional, must be unsigned 32-bit if provided).
- offset: The memory offset where the operation starts (Optional).
- numberOfBlocks: The number of blocks to be processed (Optional).
- value: A numeric value associated with the command (Optional).
Throws: SdkApiException if command is null, or if data/password validation fails.
.getCommand
RfidCommandType getCommand();
Gets the RFID command.
- Returns: the RFID command.
.setCommand
void setCommand(RfidCommandType command);
Sets the RFID command.
- command: the RFID command to set. Must not be null.
.getLocation
RfidLocation getLocation();
Gets the memory location for the operation.
- Returns: the RfidLocation.
.setLocation
void setLocation(RfidLocation location);
Sets the memory location for the operation.
- location: the RfidLocation to set.
.getData
String getData();
Gets the data to be written or used in the operation (in LZ4-compressed Base64 format).
- Returns: the compressed data.
.getPassword
Long getPassword();
Gets the access password for protected memory banks.
- Returns: the password.
.setPassword
void setPassword(Long password) throws SdkApiException;
Sets the access password for protected memory banks.
- password: an unsigned 32-bit integer representing the password.
- Throws: SdkApiException if password is not a valid unsigned 32-bit integer.
.getOffset
Integer getOffset();
Gets the memory offset where the operation starts.
- Returns: the offset.
.setOffset
void setOffset(Integer offset);
Sets the memory offset where the operation starts.
- offset: the offset to set.
.getNumberOfBlocks
Integer getNumberOfBlocks();
Gets the number of blocks to be processed.
- Returns: the number of blocks.
.setNumberOfBlocks
void setNumberOfBlocks(Integer numberOfBlocks);
Sets the number of blocks to be processed.
- numberOfBlocks: the number of blocks to set.
.getValue
Integer getValue();
Gets the numeric value associated with the command.
- Returns: the value.
.setValue
void setValue(Integer value);
Sets the numeric value associated with the command.
- value: the value to set.
RfidCommandType
RfidCommandType is an enumeration that represents the different types of RFID commands.
- SetTxPower: Sets the transmission power.
- SetRxPower: Sets the reception power.
- Write: Writes data to the RFID tag.
- Lock: Locks the RFID tag or a specific memory bank.
- Unlock: Unlocks the RFID tag or a specific memory bank.
- PermaLock: Permanently locks the RFID tag or a specific memory bank.
- PermaWrite: Permanently writes to the RFID tag.
- BlockPermaLock: Permanently locks a block of memory.
RfidLocation
RfidLocation is an enumeration that represents the memory locations on an RFID tag.
- ElectronicProductCode: Electronic Product Code memory bank.
- TagIdentifier: Tag Identifier memory bank.
- User: User memory bank.
- AccessPassword: Access Password memory location.
- KillPassword: Kill Password memory location.
RfidInputType
RfidInputType is an enumeration that represents the type of data input for RFID operations.
- ASCII: Plain text ASCII input format.
- HEX: Hexadecimal string input format.
Analytics
An object that can be configured to control analytics related functionalities.
.isTrackingEnabled
boolean isTrackingEnabled();
Gets/sets whether tracking is currently enabled.
.setTrackingEnabled
void setTrackingEnabled(boolean trackingEnabled);
Gets/sets whether tracking is currently enabled. Tracking is always defaulted to on at initialization of an app. The only way to turn analytics tracking off is with this method.
.getUserId
String getUserId();
Gets the current user ID/Client ID.
- Returns: A String representing the user ID or client ID.