2016-06-08 60 views
0

抵達ERROR_WRONG_LABEL我一直在試圖讓我的Android代碼打印到一個新的Brother打印機,但我一直在Brother打印機QL-710W

我不斷收到ERROR_WRONG_LABEL。

我也得到了信息:

D/Brother Print SDK: no such enum object for the id: -1 

這是我的代碼:

public void printLabel() { 


     Printer myPrinter = new Printer(); 
     PrinterInfo myPrinterInfo = new PrinterInfo(); 

     try { 

      myPrinterInfo.printerModel = PrinterInfo.Model.QL_710W; 
      myPrinterInfo.ipAddress = "12.1.3.45";//not real ip 
      myPrinterInfo.macAddress = ""; 
      myPrinterInfo.port = PrinterInfo.Port.NET; 
      myPrinterInfo.paperSize = PrinterInfo.PaperSize.A7; 
      myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE; 
      myPrinterInfo.numberOfCopies = 1; 

      LabelInfo mLabelInfo = new LabelInfo(); 
      mLabelInfo.labelNameIndex = 5; 
      mLabelInfo.isAutoCut = true; 
      mLabelInfo.isEndCut = true; 
      mLabelInfo.isHalfCut = false; 
      mLabelInfo.isSpecialTape = false; 


      myPrinter.setPrinterInfo(myPrinterInfo); 



      myPrinter.setLabelInfo(mLabelInfo); 

      //File downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); 

      Log.i("HEYYYY", "startCommunication = " + myPrinter.startCommunication()); 

      Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_overflow); 

      PrinterStatus printerStatus = myPrinter.printImage(map); 

      Log.i("HEYYYY", "errorCode-11 = " + printerStatus.errorCode); 
      Log.i("HEYYYY", "labelWidth = " + myPrinter.getLabelParam().labelWidth); 
      Log.i("HEYYYY", "paperWidth = " + myPrinter.getLabelParam().paperWidth); 
      Log.i("HEYYYY", "labelNameIndex " + mLabelInfo.labelNameIndex); 
      Log.i("HEYYYY", "printers " + myPrinter.getNetPrinters("QL-710W")); 
      Log.i("Label-id", myPrinter.getPrinterStatus().labelId + ""); 
      myPrinter.endCommunication(); 




     } catch(Exception e){ 

      e.printStackTrace(); 

     } 
} 

每當我把我從打印機頁面得到的mac地址,錯誤代碼變爲

ERROR_NOT_MATCH_ADDRESS. 

但沒有它(將其設置爲空字符串或註釋掉),它將更改爲

ERROR_WRONG_LABEL

請問這段代碼有什麼問題?

UPDATE:

我插入正確的MAC ID和現在的錯誤代碼是

ERROR_WRONG_LABEL 

我該怎麼辦?

+0

你可以參考這個答案http://stackoverflow.com/questions/22808548/error-wrong-label-when-trying-to-print-wireless-using-android-brother-sdk-for-la –

+0

它沒有爲我工作......我到底應該提到什麼? – gbenroscience

回答

1

在閱讀隨附的手冊後,我發現ERROR_WRONG_LABEL代碼是由於錯誤的labelNameIndex或錯誤的paperSize而發生的。

我將labelNameIndex的值設置爲15,然後它就起作用了。

我覺得任何人面臨這個問題應該嘗試labelNameIndex的各種值。

謝謝。

相關問題