gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 21:08:55 26 4
gpt4 key购买 nike

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

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

2) 以及打印后切纸用什么命令。

最佳答案

我想出的解决方案:

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

关于java - 如何从 Android 应用程序发送 ESC 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23589992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com