diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java
index 7ad3bd640..f685a58af 100644
--- a/app/src/main/java/app/fedilab/android/helper/Helper.java
+++ b/app/src/main/java/app/fedilab/android/helper/Helper.java
@@ -1174,14 +1174,20 @@ public class Helper {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return -1;
}
- final String fileName = URLUtil.guessFileName(url, null, null);
- request.allowScanningByMediaScanner();
- String myDir = sharedpreferences.getString(Helper.SET_FOLDER_RECORD, Environment.DIRECTORY_DOWNLOADS);
- request.setDestinationInExternalPublicDir(myDir, fileName);
- request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
- DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
- assert dm != null;
- return dm.enqueue(request);
+ try {
+ final String fileName = URLUtil.guessFileName(url, null, null);
+ request.allowScanningByMediaScanner();
+ String myDir = sharedpreferences.getString(Helper.SET_FOLDER_RECORD, Environment.DIRECTORY_DOWNLOADS);
+ request.setDestinationInExternalPublicDir(myDir, fileName);
+ request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+ DownloadManager dm = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
+ assert dm != null;
+ return dm.enqueue(request);
+ }catch (IllegalStateException e){
+ Toasty.error(context,context.getString(R.string.error_destination_path), Toast.LENGTH_LONG).show();
+ e.printStackTrace();
+ return -1;
+ }
}
public static String getMimeType(String url) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 74926c2de..2e89759e1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1221,4 +1221,5 @@
Media successfully added to your story!
Action disabled
Unfollow
+ Something went wrong, please check your download directory in settings.
\ No newline at end of file