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

查看你是否设置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下载后提示,无法安装文件)