title: Android Printing using custom Print service
body: <p>I am trying to write a custom android print service. I have followed the instruction mentioned in the below blog:
  <a href="https://github.com/zaki50/MyPrintServiceProject" rel="nofollow noreferrer">https://github.com/zaki50/MyPrintServiceProject</a></p>
  
  <p>I am able to create a service, which executes a print job. But after the job doesn't print any thing. My question is, what is the localId that we should provide. Is it printer ip, name? Also is there any way to know why the print job doesn't work. 
  Basically the two methods that I am concerned about are adding onStartPrinterDiscovery and OnPrintJobQueue as mentioned below:</p>
  
  <pre><code>  @Override
          public void onStartPrinterDiscovery(List&lt;PrinterId&gt; priorityList) {
              String str =     Settings.Secure.getString(getBaseContext().getContentResolver(), "enabled_print_services");
  
              Log.d("myprinter", "PrinterDiscoverySession#onStartPrinterDiscovery(priorityList: " + priorityList + ") called")
  
              final List&lt;PrinterInfo&gt; printers = new ArrayList&lt;&gt;();
              final PrinterId printerId = generatePrinterId("D8:49:2F:64:04:DB");
              final PrinterInfo.Builder builder = new PrinterInfo.Builder(printerId, "D8:49:2F:64:04:DB", PrinterInfo.STATUS_IDLE);
              PrinterCapabilitiesInfo.Builder capBuilder = new PrinterCapabilitiesInfo.Builder(printerId);
              capBuilder.addMediaSize(PrintAttributes.MediaSize.NA_LETTER, true);
              capBuilder.addMediaSize(PrintAttributes.MediaSize.NA_LETTER, false);
              capBuilder.addResolution(new PrintAttributes.Resolution("resolutionId", "default resolution", 600, 600), true);
              capBuilder.setColorModes(PrintAttributes.COLOR_MODE_COLOR | PrintAttributes.COLOR_MODE_MONOCHROME, PrintAttributes.COLOR_MODE_COLOR);
              builder.setCapabilities(capBuilder.build());
              printers.add(builder.build());
              addPrinters(printers);
          }
  
    @Override
  protected void onPrintJobQueued(PrintJob printJob) {
      Log.d("myprinter", "queued: " + printJob.getId().toString());
  
      printJob.start();
      //printJob.complete();
  
      final PrintDocument document = printJob.getDocument();
  
      final FileInputStream in = new FileInputStream(document.getData().getFileDescriptor());
      try {
          final byte[] buffer = new byte[4];
          @SuppressWarnings("unused")
          final int read = in.read(buffer);
          Log.d("myprinter", "first " + buffer.length + "bytes of content: " + toString(buffer));
      } catch (IOException e) {
          Log.d("myprinter", "", e);
      } finally {
          try {
              in.close();
          } catch (IOException e) {
              assert true;
          }
      }
      if( printJob.isStarted()){
          printJob.complete();
      }
  
  }
  </code></pre>
  
  <p>My Question is what should be printerId(or localId). How do we know if the printjob has succeeded or failed</p>