'DownloadManager or DownloadManager + IntentService
In the case of using DownloadManager system service; some people creating an IntentService and then inside the onHandleIntent method, they call DownloadManager.Request:
public class DownloadService extends IntentService {
...
@Override
protected void onHandleIntent(@Nullable Intent intent) {
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(...);
request.setNotificationVisibility(...);
...
((DownloadManager) getSystemService(DOWNLOAD_SERVICE)).enqueue(request);
}
...
}
And whenever they want to download a file, they call startService.
What is the benefit of that? Why we don't just use DownloadManger directly?! (without IntentService)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
