

Using Runnable::run will cause each download task to // download data on its own thread. Factory () // Choose an executor for downloading data. dataSourceFactory = new DefaultHttpDataSource. downloadCache = new SimpleCache ( downloadDirectory, new NoOpCacheEvictor (), databaseProvider ) // Create a factory for reading the data from the network. databaseProvider = new StandaloneDatabaseProvider ( context ) // A download cache should not evict media, so should use a NoopCacheEvictor. Note: This should be a singleton in your app. You can useĭownloadNotificationHelper.buildProgressNotification to create aįinally, you need to define the service in your AndroidManifest.xml file: getForegroundNotification(): Returns a notification to be displayed when the.WorkManagerScheduler, which uses WorkManager.The PlatformScheduler javadocs for app permission requirements. PlatformScheduler, which uses JobScheduler (Minimum API is 21).Service when requirements needed for pending downloads to progress are met.ĮxoPlayer provides these implementations: getScheduler(): Returns an optional Scheduler, which can restart the.getDownloadManager(): Returns the DownloadManager to be used.To create a DownloadService, you need to subclass it and implement its DownloadIndex: Persists the states of the downloads.HttpDataSource, and write it into a Cache. To download theĬontent, the manager will typically read the data being downloaded from a

On requirements such as network connectivity, and so on. States from (and to) a DownloadIndex, starting and stopping downloads based

DownloadManager: Manages multiple downloads, loading (and storing) their.Service allows the DownloadManager to keep running even when the app is in DownloadService: Wraps a DownloadManager and forwards commands to it.The arrow directions indicate the flow of data. Theĭiagram below shows the main classes that are involved. Send commands to the service to add, remove and control the downloads. For these use cases your app should subclass DownloadService, and

Use cases it’s desirable for downloads to continue even when your app is in theīackground. ExoPlayer provides functionality to download media for offline playback.
