2

I use Android DownloadManager to download video files from my app. It seems there is no percent in the notifications of DownloadManager. How can I implement it?

I tried to implement custom notification, but it doesn't work properly when I swipe to close or cancel it.

Code :

 request.setTitle("My Download...");
 request.setDescription("Downloading...");
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationUri(Uri.parse("file://$path"));
                request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
                request.setAllowedOverRoaming(false)

                downloadReference = downloadmanager.enqueue(request);

The Receiver :

public class DownloadBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
            long downloadId = intent.getLongExtra(
                    DownloadManager.EXTRA_DOWNLOAD_ID, 0);
            Timber.i("checkStatus0 " + downloadId);
            checkStatus(downloadId);
        }
    }
}
Mona Baharlou
  • 1,401
  • 1
  • 13
  • 26

0 Answers0