Android SDK Instruction E
Android SDK Instruction E
Android SDK Instruction E
library functions
1. openport()
Bluetooth
openport(a)
Description: Start the printer spool.
Parameter:
a: String
Input the Bluetooth Mac Address, example:“00:19:0E:A0:04:E1
Ethernet
openport(a,b)
Description: Start the printer spool.
Parameter:
a: String
Input the IP Address, for example:“192.168.1.50”
b: String
Input the printer port number, for example: “9100”
USB
openport(a,b)
Description: Start the printer spool via OTG wire.
Parameter:
a: UsbManager
Input UsbManager variable.
b: UsbDevice
Input UsbDevice variable.
2. closeport()
3. closeport(a)
4. setup(a,b,c,d,e,f,g)
Description: Set up label width, label height, print speed, print density, sensor type, gap/black mark
vertical distance、gap/black mark shift distance
Parameter:
a: string, sets up label width; unit: mm
b: string, sets up label height; unit: mm
c: string, sets up print speed, (selectable print speeds vary on different printer models)
1.0: sets print speed at 1.0"/sec
1.5: sets print speed at 1.5"/sec
2.0: sets print speed at 2.0"/sec
3.0: sets print speed at 3.0"/sec
4.0: sets print speed at 4.0"/sec
6.0: sets print speed at 6.0"/sec
8.0: sets print speed at 8.0"/sec
10.0: sets print speed at 10.0"/sec
12.0: sets print speed at 12.0"/sec
d: string, sets up print density
0~15,the greater the number, the darker the printing
e: string, sets up the sensor type to be used
0: signifies that vertical gap sensor is to be used
1: signifies that black mark sensor is to be used
f: string, sets up vertical gap height of the gap/black mark; unit: mm
g: string, sets up shift distance of the gap/black mark; unit:: mm; in the case of the average label,
set this parameter to be 0.
5. clearbuffer()
Description: Clear
Parameter: None
6. barcode(a,b,c,d,e,f,g,h,I)
7. printerfont(a,b,c,d,e,f,g)
8. sendcommand(command)
9. printlabel(a,b)
Description: Print label content
Parameter:
a: string; sets up the number of label sets
b: string, sets up the number of print copies
10. downloadpcx(a)
11. downloadbmp(a)
12. downloadttf(a)
13. formfeed()
Description: Skip to next page (of label); this function is to be used after setup Parameter: None
14. nobackfeed()
15. sendfile(a)
Description: Response the printer status. Please refer TSPL <ESC>!? command.
Parameter: int, delay time.
To use String variable to receive the data.
Note: 00 = Idle, 01 = Head Opened
Android Example for TSC Bluetooth
import com.example.tscdll.TSCActivity;
TscDll.openport("00:19:0E:A0:04:E1");
TscDll.downloadpcx("UL.PCX");
TscDll.downloadbmp("Triangle.bmp");
TscDll.downloadttf("ARIAL.TTF");
TscDll.setup(70, 110, 4, 4, 0, 0, 0);
TscDll.clearbuffer();
TscDll.sendcommand("SET TEAR ON\n");
TscDll.sendcommand("SET COUNTER @1 1\n");
TscDll.sendcommand("@1 = \"0001\"\n");
TscDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n");
TscDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n");
TscDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n");
TscDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL FONT\"\n");
TscDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
TscDll.printerfont(100, 250, "3", 0, 1, 1, "987654321");
String status = TscDll.printerstatus();
text1.setText(status);
TscDll.printlabel(2, 1);
//TscDll.sendfile("zpl.txt");
TscDll.closeport(5000);
}
}
You need input below command line to AndroidMainfest.xml first.
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Android Example TSC Ethernet
import com.example.tscwifidll.TscWifiActivity;
TscEthernetDll.openport("192.168.1.58", 9100);
TscEthernetDll.downloadpcx("UL.PCX");
TscEthernetDll.downloadbmp("Triangle.bmp");
TscEthernetDll.downloadttf("ARIAL.TTF");
TscEthernetDll.setup(70, 110, 4, 4, 0, 0, 0);
TscEthernetDll.clearbuffer();
TscEthernetDll.sendcommand("SET TEAR ON\n");
TscEthernetDll.sendcommand("SET COUNTER @1 1\n");
TscEthernetDll.sendcommand("@1 = \"0001\"\n");
TscEthernetDll.sendcommand("TEXT 100,300,\"3\",0,1,1,@1\n");
TscEthernetDll.sendcommand("PUTPCX 100,300,\"UL.PCX\"\n");
TscEthernetDll.sendcommand("PUTBMP 100,520,\"Triangle.bmp\"\n");
TscEthernetDll.sendcommand("TEXT 100,760,\"ARIAL.TTF\",0,15,15,\"THIS IS ARIAL
FONT\"\n");
TscEthernetDll.barcode(100, 100, "128", 100, 1, 0, 3, 3, "123456789");
TscEthernetDll.printerfont(100, 250, "3", 0, 1, 1, "987654321");
String status = TscEthernetDll.printerstatus();
text1.setText(status);
TscEthernetDll.printlabel(2, 1);
//TscEthernetDll.sendfile("zpl.txt");
TscEthernetDll.closeport(5000);
}
}
You need input below command line to AndroidMainfest.xml first.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Android Example TSC USB
import android.hardware.usb.UsbAccessory;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbRequest;
import com.example.tscdll.TSCUSBActivity;
test.setOnClickListener(new OnClickListener() {
if(mUsbManager.hasPermission(device))
{
TscUSB.openport(mUsbManager,device);
TscUSB.sendcommand("SIZE 3,1\r\n");
TscUSB.sendcommand("GAP 0,0\r\n");
TscUSB.sendcommand("CLS\r\n");
TscUSB.sendcommand("TEXT 100,100,\"3\",0,1,1,\"123456\"\r\n");
TscUSB.sendcommand("PRINT 1\r\n");
TscUSB.closeport(3000);
}
}
});
Note: The detail command line please refer sample code on website.