美文网首页
版本更新,DownloadManager下载后提示,无法安装文件

版本更新,DownloadManager下载后提示,无法安装文件

作者: 浩仔_Boy | 来源:发表于2016-11-11 15:30 被阅读94次

查看你是否设置Type类型。
req.setMimeType("application/vnd.android.package-archive");
这句话的意思是,在DownloadManager添加之初就指定该下载文件为APK文件。
具体添加位置:

public long startDownload(String uri, String title, String description) {
      DownloadManager.Request req = new DownloadManager.Request(Uri.parse(uri));   
      req.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);    
      req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);  
      req.setMimeType("application/vnd.android.package-archive"); 
      req.setTitle(title);    
      req.setDescription(description);    
      return dm.enqueue(req);   
      //long downloadId = dm.enqueue(req);    
      //Log.d("DownloadManager", downloadId + "");    
      //dm.openDownloadedFile()
}

相关文章

网友评论

      本文标题:版本更新,DownloadManager下载后提示,无法安装文件

      本文链接:https://www.haomeiwen.com/subject/nusfpttx.html