PrinterDiscovery

The Brady SDK PrinterDiscovery object allows the user to start discovery, stop discovery, and get information about discovered printers.

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()

startWifiPrinterDiscovery starts discovering nearby printers through the current wireless internet the user is connected to.

startBlePrinterDiscovery()

startBlePrinterDiscovery starts discovering nearby printers through Bluetooth Low Energy.

stopPrinterDiscovery()

stopPrinterDiscovery stops any discovery scan that is currently running.

getLastConnectedPrinter()

getLastConnectedPrinter returns a DiscoveredPrinterInformation object that represents the printer that was successfully connected to most recently.

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(Context context, DiscoveredPrinterInformation printerSelected, List 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.

getHaveOwnership()

getHaveOwnership returns a boolean representing the ownership the device has to the Bluetooth Low Energy printer. Ownership is a concept on the M211 and M511 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.