diff options
author | Filip Matusiak <filip.matusiak2@sonymobile.com> | 2012-08-23 15:05:05 +0200 |
---|---|---|
committer | Henrik Baard <henrik.baard@sonymobile.com> | 2013-01-16 12:56:27 +0100 |
commit | c499ca930edfb540b7161567d59dd320f0360eb8 (patch) | |
tree | fe53a071d1c0fe572ab180a6f8f7714a8058ff97 /src/com/android/browser/DownloadHandler.java | |
parent | 012dfef735bde3adda165e5add78b61c1a9862c3 (diff) | |
download | packages_apps_Browser-c499ca930edfb540b7161567d59dd320f0360eb8.zip packages_apps_Browser-c499ca930edfb540b7161567d59dd320f0360eb8.tar.gz packages_apps_Browser-c499ca930edfb540b7161567d59dd320f0360eb8.tar.bz2 |
Handle DownloadManager expceptions
Handles illegal state exceptions thrown by DownloadManager
on two ocassions:
* the directory sdcard/Downloads is an ordinary file
* could not create dirctory sdcard/Downloads
Change will log an error, additionally toast with information
will pop up.
Change-Id: If853d3218a188bc77c187362a70697126b90989d
Diffstat (limited to 'src/com/android/browser/DownloadHandler.java')
-rw-r--r-- | src/com/android/browser/DownloadHandler.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java index dee10ae..208d4ce 100644 --- a/src/com/android/browser/DownloadHandler.java +++ b/src/com/android/browser/DownloadHandler.java @@ -195,8 +195,17 @@ public class DownloadHandler { request.setMimeType(mimetype); // set downloaded file destination to /sdcard/Download. // or, should it be set to one of several Environment.DIRECTORY* dirs depending on mimetype? - request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); - // let this downloaded file be scanned by MediaScanner - so that it can + try { + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); + } catch (IllegalStateException ex) { + // This only happens when directory Downloads can't be created or it isn't a directory + // this is most commonly due to temporary problems with sdcard so show appropriate string + Log.w(LOGTAG, "Exception trying to create Download dir:", ex); + Toast.makeText(activity, R.string.download_sdcard_busy_dlg_title, + Toast.LENGTH_SHORT).show(); + return; + } + // let this downloaded file be scanned by MediaScanner - so that it can // show up in Gallery app, for example. request.allowScanningByMediaScanner(); request.setDescription(webAddress.getHost()); |