我正在尝试为标签打印机QL-720NW打印无线,但我正在获取ERROR_NOT_MATCH_ADDRESS?

时间:2016-04-14 05:56:27

标签: java android printing

我正在使用的准则。

我在textview上打印错误代码。这是给出了ERROR_NOT_MATCH ADDRESS。我通过一些链接和兄弟Sdk使用这个。

我正在使用此链接Link using

 public class printerApp extends Activity {
 TextView mytext;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mytext=(TextView)findViewById(R.id.mytext);


        printTemplateSample();
    }
    public void printTemplateSample() {

        Printer myPrinter = new Printer();
        PrinterInfo myPrinterInfo = new PrinterInfo();
        PrinterStatus printResult = new PrinterStatus();
        LabelInfo mLabelInfo=new LabelInfo();
        try{

            myPrinterInfo = myPrinter.getPrinterInfo();
            myPrinterInfo.ipAddress="192.168.0.122";
            myPrinterInfo.macAddress="00:80:92:d7:f4:0d";
            myPrinterInfo.printerModel= PrinterInfo.Model.QL_720NW;
            myPrinterInfo.printMode= PrinterInfo.PrintMode.FIT_TO_PAGE;
            myPrinterInfo.port= PrinterInfo.Port.NET;
            myPrinterInfo.paperPosition= PrinterInfo.Align.CENTER;

           myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;
            myPrinterInfo.orientation = PrinterInfo.Orientation.PORTRAIT;
            myPrinterInfo.halftone = PrinterInfo.Halftone.PATTERNDITHER;
            myPrinterInfo.align = PrinterInfo.Align.LEFT;
            myPrinterInfo.margin.left = 0;
            myPrinterInfo.valign = PrinterInfo.VAlign.TOP;
            myPrinterInfo.customPaperLength = 0;
            myPrinterInfo.customPaperWidth = 0;
            myPrinterInfo.customFeed = 0;
            myPrinterInfo.paperPosition = PrinterInfo.Align.CENTER;
            myPrinterInfo.dashLine = false;
          //  myPrinterInfo.isSpecialTape=
            myPrinterInfo.numberOfCopies = 1;


            myPrinterInfo.labelNameIndex= 15;
            myPrinterInfo.isAutoCut = false;
            myPrinterInfo.isCutAtEnd =false;
          //  myPrinter.setLabelInfo(mLabelInfo);
            myPrinter.setPrinterInfo(myPrinterInfo);
            //myPrinter.setPrinterInfo(myPrinterInfo);


            // Create bitmap
            Bitmap bmap = BitmapFactory.decodeResource(getResources(), R.mipmap.dcs);

            try {
                mytext.append("Start" + "\n");

                myPrinter.startCommunication();
                PrinterStatus printerStatus = myPrinter.printImage(bmap);

                myPrinter.endCommunication();

                mytext.append(printerStatus.errorCode.toString() + "\n");

            } catch (Exception e) {
                mytext.setText(e.toString());
            }

        } catch (Exception e) {
            mytext.setText(e.toString());
            //e.printStackTrace();
        }
    }
    }

我从资源文件夹打印图像也在尝试打印文本。但每次我收到上面显示的错误

提前感谢所有观众请帮助我.....

1 个答案:

答案 0 :(得分:1)

我解决了这个问题通过在我的代码中集成Sdk演示... Sdk download with sample demo

适用于所有兄弟打印机

  • 我在我的代码中设置了打印机所需的所有首选项。