Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/android/BackgroundDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.database.CursorIndexOutOfBoundsException;

import android.net.Uri;

/**
Expand Down Expand Up @@ -357,10 +359,18 @@ public void onReceive(Context context, Intent intent) {
Cursor cursor = mgr.query(query);
int idxURI = cursor.getColumnIndex(DownloadManager.COLUMN_URI);
cursor.moveToFirst();
String uri = cursor.getString(idxURI);
String uri;

Download curDownload = activDownloads.get(uri);
try {
uri = cursor.getString(idxURI);
} catch (CursorIndexOutOfBoundsException e) {
// Already removed from the list / list is empty due to cancellation
// Can't do anything else since there's no DL to get
// context from.
return;
}

Download curDownload = activDownloads.get(uri);
try {
long receivedID = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1L);
query.setFilterById(receivedID);
Expand Down Expand Up @@ -396,4 +406,4 @@ public void copyTempFileToActualFile(Download curDownload) {
curDownload.getCallbackContextDownloadStart().error("Cannot copy from temporary path to actual path");
}
}
}
}