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

如何成为Android开发高手

 2010-08-31 00:43:00 来源:WEB开发网   
核心提示:152153}154155/**156157 * 构建文件下载器158159 * @param downloadUrl 下载路径160161 * @param fileSaveDir 文件保存目录162163 * @param threadNum 下载线程数164165 */166167public FileDownl

152

153}

154

155/**

156

157 * 构建文件下载器

158

159 * @param downloadUrl 下载路径

160

161 * @param fileSaveDir 文件保存目录

162

163 * @param threadNum 下载线程数

164

165 */

166

167public FileDownloader(Context context, String downloadUrl, File fileSaveDir, int threadNum) {

168

169try {

170

171this.context = context;

172

173this.downloadUrl = downloadUrl;

174

175fileService = new FileService(context);

176

177this.url = new URL(downloadUrl);

178

179if(!fileSaveDir.exists()) fileSaveDir.mkdirs();

180

181this.threads = new DownloadThread[threadNum];

182

183HttpURLConnection conn = (HttpURLConnection) url.openConnection();

184

185conn.setConnectTimeout(6*1000);

186

187conn.setRequestMethod("GET");

188

189conn.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, */*");

190

191conn.setRequestProperty("Accept-Language", "zh-CN");

192

193conn.setRequestProperty("Referer", downloadUrl);

194

195conn.setRequestProperty("Charset", "UTF-8");

196

197conn.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)");

198

199conn.setRequestProperty("Connection", "Keep-Alive");

上一页  8 9 10 11 12 13 14 15 16 17 18  下一页

Tags:如何 成为 Android

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接