android蓝牙打印机连接?

android蓝牙打印机连接?,android,bluetooth,Android,Bluetooth,我有J2ME应用程序将数据字节打印到打印机上。 但现在,我必须将该代码转换为android代码 我的问题是: 我无法通过蓝牙将数据字节[]从我的设备Galaxy Tab Froyo发送到移动打印机 下面是我的简单代码: UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); BluetoothSocket btSocket btSocket = device.createRfcommSocketToServi

我有J2ME应用程序将数据字节打印到打印机上。 但现在,我必须将该代码转换为android代码

我的问题是: 我无法通过蓝牙将数据字节[]从我的设备Galaxy Tab Froyo发送到移动打印机

下面是我的简单代码:

UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothSocket btSocket btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
btSocket.connect();
OutputStream outStream = btSocket.getOutputStream();
String message = "this is message";
byte[] msgBuffer = message.getBytes();
outStream.write(msgBuffer.length);
outStream.write(msgBuffer);
当我看到LogCat时,它表明我已经完成了所有的过程,没有错误

有人能帮我吗

提前感谢,


aql

我想到的第一件事是你忘了写的
outStream.close()
。虽然我很可能错了

但你需要告诉打印机你要打印什么(文本、img、条形码)。所有蓝牙打印机都使用sam EHExademic代码来处理该问题。尝试:

        byte[] arrayOfByte1 = { 27, 33, 0 }; //This defines the FontType we use 2 in the next line for 0 thats the default Font.
        byte[] printformat = { 0x1B, 0x21,(byte)(0x8|arrayOfByte1[2]) }; 

        btoutputstream = btsocket.getOutputStream();

        btoutputstream.write(printformat);
        btoutputstream.write(printAlign);
        btoutputstream.write(message.getBytes());

是的,我也很奇怪。打印机可能会等待一整页的数据(或表单提要)或数据结束后才开始打印。是否尝试使用?Like
BufferedWrited writer=新的BufferedWriter(超出流,大小)。然后使用不同的缓冲区大小值进行实验。