如何从Android应用程序发送ESC命令?

时间:2014-05-11 07:15:21

标签: java android sockets

我正在开发Android应用程序,需要在打印后发送ESC命令来剪纸。

1)请指导我如何从android发送ESC命令。

2)打印后使用什么命令进行剪纸。

1 个答案:

答案 0 :(得分:1)

我提出的解决方案:

Socket sock;
PrintWriter oStream;
DataInputStream is;

sock = new Socket(ip, port);
is = new DataInputStream(sock.getInputStream());
oStream = new PrintWriter(sock.getOutputStream());

oStream.println(new char[]{0x1D, 0x56, 0x41, 0x10}); // 0x1D, 0x56, 0x41 is for paper cut and 0x10 is for line feed.

oStream.flush();
oStream.close();
sock.close();