To use the ImageDownloaderSDK, ensure the following permissions are declared in your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
Before downloading images, ensure the necessary permissions are requested from the user. Handle permissions in your activity or fragment.
Use the ImageDownloadManager to download images:
ImageDownloadManager downloadManager = new ImageDownloadManager();
int downloadId = downloadManager.startDownload(imageUrl, localFilePath, new DownloadListener() {
@Override
public void onProgress(int downloadId, int progress) {
// Update progress bar or UI
}
@Override
public void onSuccess(int downloadId, String filePath) {
// Handle successful download
}
@Override
public void onError(int downloadId, DownloadError error) {
// Handle download error
}
});
There is an example usage of the ImageDownloaderSDK in the MainActivity class. For details, please refer to the MainActivity file in the source code.