1

Bluetooth経由でプリンターに接続し、テキストを印刷するアプリケーションに取り組んでいます。Bluetoothでプリンターに接続し、BluetoothSocketからoutputStreamを取得してテキストを書き込むことができます。しかし、プリンターには何も印刷されません... 注意深く確認しましたが、例外はありません。私のコードで何が間違っていたのか助けてください???`私はCanon MX430プリンターをテストに使用しました..これが私のコードです

String MY_PRINTER_MAC_ADDRESS="00:12:FF:67:89";// Printer Mac Address
private UUID applicationUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
String test="testing123234123"; 

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(mDeviceAddress);
mBluetoothSocket = mBluetoothDevice.createRfcommSocketToServiceRecord(applicationUUID);
Method m = mBluetoothDevice.getClass().getMethod("createRfcommSocket", new Class[] {     int.class });
mBluetoothSocket = (BluetoothSocket) m.invoke(mBluetoothDevice, 1);
mBluetoothAdapter.cancelDiscovery();
mBluetoothSocket.connect();
OutputStream os=MainActivity.mBluetoothSocket.getOutputStream();    
byte[] buffer=test.getBytes();
os.write(buffer);       
os.flush();
os.close();`
4

1 に答える 1

0

私は過去にこれを試しましたが、サーマルプリンターを使用しています。そこでは、ストリームに書き込まれるデータが印刷されるために特定のプロトコルに従わなければならないことが期待されていました。問題は同様の条件にある可能性があります。

于 2013-07-02T06:26:52.203 に答える