From: Reimar Döffinger Date: Tue, 15 Dec 2015 20:25:53 +0000 (+0100) Subject: Print reason for failed download. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=646486e09434e65b127bf900d86b3b70fb12158b Print reason for failed download. --- diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 8ec7d2c..523a410 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -142,11 +142,17 @@ public class DictionaryManagerActivity extends ActionBarActivity { .getInt(cursor .getColumnIndex(DownloadManager.COLUMN_STATUS)); if (DownloadManager.STATUS_SUCCESSFUL != status) { + final int reason = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_REASON)); Log.w(LOG, "Download failed: status=" + status + - ", reason=" + cursor.getString(cursor - .getColumnIndex(DownloadManager.COLUMN_REASON))); - new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(getString(R.string.downloadFailed, dest)).setNeutralButton("Close", null).show(); + ", reason=" + reason); + String msg = Integer.toString(reason); + switch (reason) { + case DownloadManager.ERROR_FILE_ALREADY_EXISTS: msg = "File exists"; break; + case DownloadManager.ERROR_FILE_ERROR: msg = "File error"; break; + case DownloadManager.ERROR_INSUFFICIENT_SPACE: msg = "Not enough space"; break; + } + new AlertDialog.Builder(context).setTitle(getString(R.string.error)).setMessage(getString(R.string.downloadFailed, reason)).setNeutralButton("Close", null).show(); return; }