蓝牙打印机不打印(Android)

时间:2015-10-14 06:48:05

标签: android printing bluetooth

我正在为我的“Woosim S30 / 40”打印机开发一个Android应用程序。打印机 与我的手机配对,代码中没有例外。但是当我在蓝牙插座上写字时,只是数据指示灯略微闪烁,没有任何反应(没有打印。)我尝试了很多代码来自堆栈流量和应用程序形成谷歌商店,但同样的事情发生。 打印机样本纸显示如下设置

  • 模式=蓝牙
  • 序列= 57600 BPS
  • 7数据位
  • ODD Parity
  • 2停止位
  • 密度=媒介
  • Mark = No USe
  • 传感器=低
  • 命令=类型0
  • PWDN = NO USe

打印事件代码:(从堆栈溢出使用)

mPrint = (Button) findViewById(R.id.mPrint);
mPrint.setOnClickListener(new View.OnClickListener() {
    public void onClick(View mView) {
        Thread t = new Thread() {
            public void run() {
                try {
                    OutputStream os = mBluetoothSocket.getOutputStream();
                    String BILL = "";
                    BILL = "\nInvoice No: ABCDEF28060000005" + "    " + "04-08-2011\n";
                    BILL = BILL + "-----------------------------------------";
                    BILL = BILL + "\n\n";
                    BILL = BILL + "Total Qty:" + "      " + "2.0\n";
                    BILL = BILL + "Total Value:" + "     " + "17625.0\n";
                    BILL = BILL + "-----------------------------------------\n";
                    os.write(BILL.getBytes());

                    // Setting height
                    int gs = 29;
                    os.write(intToByteArray(gs));
                    int h = 104;
                    os.write(intToByteArray(h));
                    int n = 162;
                    os.write(intToByteArray(n));

                    // Setting Width
                    int gs_width = 29;
                    os.write(intToByteArray(gs_width));
                    int w = 119;
                    os.write(intToByteArray(w));
                    int n_width = 2;
                    os.write(intToByteArray(n_width));

                    // Print BarCode
                    int gs1 = 29;
                    os.write(intToByteArray(gs1));
                    int k = 107;
                    os.write(intToByteArray(k));
                    int m = 73;
                    os.write(intToByteArray(m));

                    String barCodeVal = "ASDFC028060000005";// "HELLO12345678912345012";
                    System.out.println("Barcode Length : " + barCodeVal.length());
                    int n1 = barCodeVal.length();
                    os.write(intToByteArray(n1));

                    for (int i = 0; i < barCodeVal.length(); i++) {
                        os.write((barCodeVal.charAt(i) + "").getBytes());
                    }

                } catch (Exception e) {
                    Log.e("Main", "Exe ", e);
                }
            }
        };
        t.start();
    }
});

0 个答案:

没有答案