巨人肩:
Android WebView文件下载实现(非常推荐,注释很全:加入下载队列执行、注册广播)
有说明如何去除通知栏通知
讲到了文件id的获取
我在实际使用的时候,需要自动地去对下载完的文件进行操作,所以涉及到如下动作:
1.记录下载文件名
2.下载完成后,处理文件
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
//下载完成了
if (downloadId == intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)) {
Uri uri = downloadManager.getUriForDownloadedFile(downloadId);
storeFileUri();//重复下载的问题,即name.zip会在下次下载时自动加name-1.zip或者name-xx.zip
handler4Process.sendEmptyMessage(DownloadComplete);
}
}
}
};