title: Download file generated by javascript in android webview
body: <p>I have an android app with a webview.</p>
  
  <p>Whenever a user clicks on a button, JavaScript creates a blob, puts text in it and downloads it.</p>
  
  <p>Here's the function that does this:</p>
  
  <pre><code>function saveTextAsFile(A)
  {
      FillTextToWrite(A);
      var textFileAsBlob = new Blob([textToWrite], {
          type: 'text/plain'
      });
      var downloadLink = document.createElement("a");
      downloadLink.download = "Analysis.txt";
      downloadLink.innerHTML = "Download File";
      if (window.webkitURL != null)
      {
          downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
      }
      else
      {
          downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
          downloadLink.onclick = destroyClickedElement;
          downloadLink.style.display = "none";
          document.body.appendChild(downloadLink);
      }
  
      downloadLink.click();
  }
  </code></pre>
  
  <p>It works fine in any browser, but when I try to download it in the app, nothing happens.</p>
  
  <p>Is there a way to download the blob in the app or is it easier to change the JavaScript?</p>
  
  <p>I need the JavaScript to work on browser as well as on the android app, so sending the blob to the android app in JavaScript will not work on browser.</p>