title: print from android device on a windows shared printer
body: <p>I have to print via Windows Shared Printer on Android. I use the below code using jcifs-1.3.19.jar.</p>
  
  <pre><code> private void doSmbPrinting() {
      try {
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy);
  
          NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication("", "username", "password");
  
          SmbFile smbFile = new SmbFile("smb://username:password@10.0.0.53/SHARENAME/Untitled", authentication);
          SmbFileOutputStream uncOut = new SmbFileOutputStream(smbFile); // Exception is in this line
          PrintWriter uncPrint = new PrintWriter(uncOut);
          uncPrint.println("print text ");
          uncPrint.flush();
  
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p><strong>I am getting below error:</strong></p>
  
  <blockquote>
    <p>12-21 14:19:13.729 26993-26993/com.abdu.sampleandroid W/System.err: jcifs.smb.SmbException: The parameter is incorrect.
            at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563)
            at jcifs.smb.SmbTransport.send(SmbTransport.java:663)
         12-21 14:19:13.730 26993-26993/com.abdu.sampleandroid W/System.err:     at jcifs.smb.SmbSession.send(SmbSession.java:238)
            at jcifs.smb.SmbTree.send(SmbTree.java:119)
            at jcifs.smb.SmbFile.send(SmbFile.java:775)
            at jcifs.smb.SmbFile.open0(SmbFile.java:992)
            at jcifs.smb.SmbFile.open(SmbFile.java:1009)
         12-21 14:19:13.731 26993-26993/com.abdu.sampleandroid W/System.err:     at jcifs.smb.SmbFileOutputStream.(SmbFileOutputStream.java:142)
            at jcifs.smb.SmbFileOutputStream.(SmbFileOutputStream.java:97)
            at jcifs.smb.SmbFileOutputStream.(SmbFileOutputStream.java:67)
            at com.abdu.sampleandroid.MainActivity.doSmbPrinting(MainActivity.java:59)
            at com.abdu.sampleandroid.MainActivity.doPrint(MainActivity.java:47)
            at com.abdu.sampleandroid.MainActivity.onResume(MainActivity.java:41)</p>
  </blockquote>
  
  <p>Please help me on the issue. I am able to add the shared printer in Mac with the same smb url, and made prints. Its working(only frustration is its asking credentials every time). How can we make a print from the Android device on a windows shared printer?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>with above code i can write to a file in shared folder. only change is </p>
  
  <pre><code> SmbFile smbFile = new SmbFile("smb://username:password@10.0.0.53/FOLDERNAME/file.txt", authentication);
  </code></pre>
  
  <p>This also works, no need to give username and password in URL. Since there is NtlmPasswordAuthentication</p>
  
  <pre><code> SmbFile smbFile = new SmbFile("smb://10.0.0.53/FOLDERNAME/file.txt", authentication);
  </code></pre>
  
  <p>So I doubt this code is to write a file in shared folder(OR writing on to printer is ok). If that is the case how we make a print using jcifs.smb?</p>