]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Merge pull request #27 from spinclick/master
authorReimar Döffinger <rdoeffinger@users.noreply.github.com>
Sat, 30 Jan 2016 09:11:33 +0000 (10:11 +0100)
committerReimar Döffinger <rdoeffinger@users.noreply.github.com>
Sat, 30 Jan 2016 09:11:33 +0000 (10:11 +0100)
Prevent crash when DownloadManager is disabled

src/com/hughes/android/dictionary/DictionaryManagerActivity.java

index 159a7f0abf5037a9516e65e6bf4536c8ee4411f0..4b1723fe0b46fff71d5d73b83c1b42772143627a 100644 (file)
@@ -616,6 +616,14 @@ public class DictionaryManagerActivity extends ActionBarActivity {
         final DownloadManager.Query query = new DownloadManager.Query();
         query.setFilterByStatus(DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_PENDING | DownloadManager.STATUS_RUNNING);
         final Cursor cursor = downloadManager.query(query);
+
+        if (cursor == null) {
+            new AlertDialog.Builder(DictionaryManagerActivity.this).setTitle(getString(R.string.error))
+                    .setMessage(getString(R.string.downloadFailed, "Couldn't query Download Manager"))
+                    .setNeutralButton("Close", null).show();
+            return;
+        }
+
         while (cursor.moveToNext()) {
             if (downloadUrl.equals(cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_URI))))
                 break;