|
|
|
@ -7,17 +7,11 @@ import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
import android.os.Environment;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* author: Created by lixiaotong on 2018/10/17
|
|
|
|
|
* e-mail: 516030811@qq.com
|
|
|
|
|
*/
|
|
|
|
|
public class DownloadUtils {
|
|
|
|
|
//下载器
|
|
|
|
|
private DownloadManager downloadManager;
|
|
|
|
@ -38,12 +32,9 @@ public class DownloadUtils {
|
|
|
|
|
//创建下载任务
|
|
|
|
|
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
|
|
|
|
//移动网络情况下是否允许漫游
|
|
|
|
|
request.setAllowedOverRoaming(false);
|
|
|
|
|
request.setAllowedOverRoaming(true);
|
|
|
|
|
//在通知栏中显示,默认就是显示的
|
|
|
|
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
|
|
|
|
|
request.setTitle("通知标题,随意修改");
|
|
|
|
|
request.setDescription("新版***下载中...");
|
|
|
|
|
request.setVisibleInDownloadsUi(true);
|
|
|
|
|
request.setVisibleInDownloadsUi(false);
|
|
|
|
|
|
|
|
|
|
//设置下载的路径
|
|
|
|
|
File file = new File(mContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), name);
|
|
|
|
|