Fix crashing when selecting release notes on some devices

This commit is contained in:
Wang Han
2017-03-26 23:55:11 +08:00
committed by topjohnwu
parent 435251ca41
commit 4c7bdbb284
2 changed files with 10 additions and 4 deletions

View File

@@ -91,10 +91,12 @@ public class Utils {
isDownloading = true;
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
request.setDestinationUri(Uri.fromFile(file));
receiver.setDownloadID(downloadManager.enqueue(request));
if (link != null) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(link));
request.setDestinationUri(Uri.fromFile(file));
receiver.setDownloadID(downloadManager.enqueue(request));
}
receiver.setFilename(filename);
context.registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}