Wednesday, 11 September 2013

download files using download manager in android

here is simple few lines of code that can be implemented to initiate instant download

 DownloadManager mgr = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);

               Uri downloadUri = Uri.parse("www.example.com/name.mp4");
               DownloadManager.Request request = new DownloadManager.Request(
                       downloadUri);

               request.setAllowedNetworkTypes(
                       DownloadManager.Request.NETWORK_WIFI
                               | DownloadManager.Request.NETWORK_MOBILE)
                       .setAllowedOverRoaming(false)
                       .setDescription("mohammediatechnologies.in")
                       .setNotificationVisibility(request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
                       .setDestinationInExternalPublicDir("/videotest", "yourfilename.ext");
                           
               mgr.enqueue(request);

1 comment: