1. Android USB Host basics
Android devices that support USB host mode can enumerate attached devices through the `UsbManager`. The system reports each device with a vendor ID (VID) and product ID (PID). For POS printers you will usually see a class code of 0 (vendor‑specific) because they use ESC/POS commands over a virtual COM port. Use `UsbManager.getDeviceList()` to retrieve the map and filter by the known VID/PID of your Epson TM‑T88III (0x04b8/0x0202) or other models.
2. Choose an SDK or raw ESC/POS
Two common approaches exist: * **Epson ePOS SDK** – provides high‑level printing APIs and handles USB, Bluetooth and network connections automatically. It is the most reliable choice for Epson printers. * **Raw ESC/POS** – open the USB interface yourself, claim it, and write the command bytes directly. This works with any ESC/POS‑compatible printer but requires manual handling of flow control and character encoding.
3. Declare permissions and filter the device
Add the following to `AndroidManifest.xml`: ```xml <uses-feature android:name="android.hardware.usb.host" /> <uses-permission android:name="android.permission.USB_PERMISSION" /> ``` Create an `intent-filter` for the printer’s VID/PID so the system prompts the user to grant access: ```xml <intent-filter> <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/> </intent-filter> ``` When the user approves, the `UsbDevice` instance can be passed to your printing routine.
4. Sample code – open the device and send a test line
The snippet below demonstrates a minimal raw ESC/POS implementation. It opens the first endpoint of the printer, writes a simple text line, and issues a cut command. ```java UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); UsbDevice printer = null; for (UsbDevice d : manager.getDeviceList().values()) { if (d.getVendorId() == 0x04B8 && d.getProductId() == 0x0202) { // Epson TM‑T88III printer = d; break; } } if (printer == null) throw new IllegalStateException("Printer not found");
UsbDeviceConnection connection = manager.openDevice(printer); if (connection == null) throw new IllegalStateException("Permission denied");
UsbInterface intf = printer.getInterface(0); connection.claimInterface(intf, true); UsbEndpoint endpoint = intf.getEndpoint(0); // bulk out
byte[] cmd = new byte[]{ 0x1B, 0x40, // Initialize printer 'H','e','l','l','o',' ','W','o','r','l','d','!','\n', 0x1D, 0x56, 0x00 // Full cut }; int transferred = connection.bulkTransfer(endpoint, cmd, cmd.length, 2000); Log.d("POS", "Sent " + transferred + " bytes"); connection.releaseInterface(intf); connection.close(); ```
5. Debugging tips
If the printer appears only at the kernel level, verify that the tablet’s kernel includes the `usbserial` and `ftdi_sio` modules; many POS printers expose a CDC‑ACM interface that Android can treat as a serial device. Use the "USB Host Diagnostic" app to confirm the endpoint type (bulk vs. interrupt). When using the Epson SDK, call `Epos2Callback` to capture connection errors; common failures are missing permission or unsupported USB mode on the device.
Takeaway: Use Android’s USB Host API (or Epson’s ePOS SDK) to claim the printer’s bulk endpoint, then send ESC/POS bytes for a quick test print.
People also ask
Do I need root access to use a USB POS printer on Android?
No. As long as the device supports USB host mode and you request the proper permission, you can communicate with the printer from user space.
Can I print over Bluetooth instead of USB?
Yes. Both the Epson ePOS SDK and most ESC/POS libraries provide Bluetooth socket support; the code pattern is identical, only the connection object changes.
What if my tablet does not list the printer in `UsbManager.getDeviceList()`?
Check that the OTG cable is functional, the tablet’s kernel includes the required USB‑serial drivers, and that the printer is powered on. Some low‑cost tablets need a powered USB hub.
Inspired by a public discussion on Stack Overflow. This article is an original explanation for learners.