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
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: The M611 Edison is the only printer that supports Bluetooth Classic in the Android SDK. 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
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.
.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.
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
- ConnectionType
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. 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
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. 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
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.
.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);
setAutomaticShutoffTime sets the automatic shutdown time of the printer in minutes. Only applicable to the M211 and M511.
- timeInMinutes: An Integer that represents the amount of minutes it takes for the connected printer to shut down automatically. If this is set to zero, it will not change the current value.
.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.
.setSupplyDatabase
**void setSupplyDatabase(InputStream iStream) throws IOException, ParserConfigurationException, SAXException;
setSupplyDatabase allows a user to provide a Brady Supply Database to the SDK which will override the embedded one.
- iStream: An InputStream that represents the database data. The original file MUST be an XML or a BIN to be deserialized correctly once converted to an InputStream
PrinterUpdateListener
The Brady SDK PrinterUpdateListener interface can be implemented to an Activity.
PrinterUpdate
void PrinterUpdate(List
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.
- 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.
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.
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 printer before cutting. - For example, caling "setCutAfterRowValue(2)" will tell the printer to cut after every 2 rows of labels.
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.
Analytics
An object that can be configured to control analytics related functionalities.
AnalyticsFactory.getAnalytics(Context)
**Analytics AnalyticsFactory.getAnalytics(Context)
AnalyticsFactory.getAnalytics initializes an Analytics object to allow a user to enable/disable analytics tracking and to see the current tracking status.
.isTrackingEnabled
boolean isTrackingEnabled();
isTrackingEnabled returns a Boolean representing if analytics are actively tracking. True, if enabled. False, if disabled.
.setTrackingEnabled
void setTrackingEnabled(boolean trackingEnabled);
setTrackingEnabled toggled analytics tracking on and off. Tracking is always defaulted to on at initialization of an app. The only way to turn analytics tracking off is with this method.