蓝牙打印机中的打印问题

时间:2013-07-02 06:21:42

标签: android printing bluetooth

我正在研究通过蓝牙与打印机连接并打印一些文本的应用程序。我可以通过蓝牙与打印机连接,然后从BluetoothSocket获取outputStream并写一些文本。但它没有在打印机中打印任何东西......我仔细检查过没有例外。请帮助我在我的代码中做错了什么???`我用过佳能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();`

1 个答案:

答案 0 :(得分:0)

我过去曾尝试使用热敏打印机。期望是要写入流的数据必须遵循某些协议才能打印。问题可能是类似的问题。

相关问题