私の一日を無駄にしますが、サーマルプリンタがハーフテキストを受信して印刷する理由を理解できませんでした。それは完全に58mm Mini Bluetooth Thermal Printer
の仕事です。しかし、サーマルプリンターに入ったらLESHP 80mm Wireless Bluetooth Thermal
このプリンターは半分のテキストのみを受け取ります。Bluetooth Thermal printer print half String
ここに私のコード:
void findBT() {
try {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBluetooth, 0);
}
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName().contains("Printer")) {
mmDevice = device;
}
}
}
else {
Toast.makeText(this,"device not pair.",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
void SendDateBT() throws IOException {
try {
// Standard SerialPortService ID
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid);
mmSocket.connect();
mmOutputStream = mmSocket.getOutputStream();
mmInputStream = mmSocket.getInputStream();
mmOutputStream.write(mytext.getBytes());
mmOutputStream.flush();
mmOutputStream.close();
mmInputStream.close();
mmSocket.close();
} catch (Exception e) {
e.printStackTrace();
}
}
私は領収書を印刷したいとき、私はこの2つの関数を呼び出す:
findBT();
SendDatBt();
接続終了時にデバイスが印刷を停止する可能性はありますか?フラッシュ呼び出し後、20秒間スリープ状態を追加してみてください。もっと印刷されますか?そうであれば、APIがジョブがクリーンな仕方で終了するのを待つ方法を提供しているかどうかを調べます(つまり、任意の時間だけスリープ状態ではない)。 – Hector
印刷された文書についての画像を提供してください – nhoxbypass
私の他のコメントに加えて、EOFを送ろうとしましたか? – Hector