publicstaticvoidonDownloadStartNoStream(Activity activity,String url,String userAgent,String contentDisposition,String mimetype,String referer,boolean privateBrowsing,long contentLength){...// let this downloaded file be scanned by MediaScanner - so that it can// show up in Gallery app, for example.
request.allowScanningByMediaScanner();
request.setDescription(webAddress.getHost());// XXX: Have to use the old url since the cookies were stored using the// old percent-encoded url.String cookies =CookieManager.getInstance().getCookie(url, privateBrowsing);+// add start+if(referer ==null|| referer.isEmpty()) referer ="https://www.baidu.com";+// add end
request.addRequestHeader("cookie", cookies);
request.addRequestHeader("User-Agent", userAgent);
request.addRequestHeader("Referer", referer);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);//request.setUserAgent(userAgent);...}