pdf not getting downloaded in pre-lollipop devices using download manager
<p>I am trying to download pdf using <code>DownloadManager</code>. </p>

<p>I am passing parameter in link and from server pdf file generated and downloaded into device. so my download link would be some what like this </p>

<blockquote>
  <p><code>http://example.com/gen.php?data={......}</code></p>
</blockquote>

<p><strong>My Code :</strong></p>

<pre><code>final Request request = new Request(Uri.parse(fromUrl));
request.setMimeType("application/pdf");
request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(path, "ELALA_MANIFEST_" + System.currentTimeMillis() + ".pdf");

final DownloadManager dm = (DownloadManager) context
        .getSystemService(Context.DOWNLOAD_SERVICE);
try {
    try {
        dm.enqueue(request);
    } catch (SecurityException e) {
        request.setNotificationVisibility(Request.VISIBILITY_VISIBLE);
        Log.e("Error", e.toString());
        dm.enqueue(request);
    }

}
// if the download manager app has been disabled on the device
catch (IllegalArgumentException e) {
    openAppSettings(context,
            AdvancedWebView.PACKAGE_NAME_DOWNLOAD_MANAGER);
}
</code></pre>

<p>This <strong>works fine in device with api level 21 (lollipop) and above</strong>. but in lower version pdf not getting downloaded. and notification pops like,</p>

<blockquote>
<pre><code>&lt;untitled&gt; download unsuccessful
</code></pre>
</blockquote>

<p>I know it something has to do with <code>setMimeType</code>, but  don't know what.</p>

<p>Any Help will be appreciated.</p>