WEB开发网
开发学院手机开发Android 开发 如何成为Android开发高手 阅读

如何成为Android开发高手

 2010-08-31 00:43:00 来源:WEB开发网   
核心提示:034035private FileDownloader downloader;036037038039public DownloadThread(FileDownloader downloader, URL downUrl, RandomAccessFile saveFile, int block, int star

034

035private FileDownloader downloader;

036

037

038

039public DownloadThread(FileDownloader downloader, URL downUrl, RandomAccessFile saveFile, int block, int startPos, int threadId) {

040

041this.downUrl = downUrl;

042

043this.saveFile = saveFile;

044

045this.block = block;

046

047this.startPos = startPos;

048

049this.downloader = downloader;

050

051this.threadId = threadId;

052

053this.downLength = startPos - (block * (threadId - 1));

054

055}

056

057

058

059@Override

060

061public void run() {

062

063if(downLength < block){//未下载完成

064

065try {

066

067HttpURLConnection http = (HttpURLConnection) downUrl.openConnection();

068

069http.setRequestMethod("GET");

070

071http.setRequestProperty("Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");

072

073http.setRequestProperty("Accept-Language", "zh-CN");

074

075http.setRequestProperty("Referer", downUrl.toString());

076

077http.setRequestProperty("Charset", "UTF-8");

078

079http.setRequestProperty("Range", "bytes=" + this.startPos + "-");

080

081http.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");

上一页  14 15 16 17 18 19 20 21 22 23 24  下一页

Tags:如何 成为 Android

编辑录入:coldstar [复制链接] [打 印]
赞助商链接