From 0f7ffc320ead342c21577416bcffd71583c48cfd Mon Sep 17 00:00:00 2001 From: sonalyadav Date: Thu, 19 Dec 2024 19:29:28 +0530 Subject: [PATCH] fixed null values --- .../main/java/fr/free/nrw/commons/utils/DownloadUtils.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/utils/DownloadUtils.kt b/app/src/main/java/fr/free/nrw/commons/utils/DownloadUtils.kt index 08c030e33..ced34f428 100644 --- a/app/src/main/java/fr/free/nrw/commons/utils/DownloadUtils.kt +++ b/app/src/main/java/fr/free/nrw/commons/utils/DownloadUtils.kt @@ -61,7 +61,10 @@ object DownloadUtils { req: DownloadManager.Request, ) { val systemService = - activity.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager - systemService?.enqueue(req) + activity.getSystemService(Context.DOWNLOAD_SERVICE) as? DownloadManager + if (systemService != null) { + systemService.enqueue(req) + } + else { Timber.e("DownloadManager service not available.") } } }