URL u = new URL(url);HttpURLConnection c = (HttpURLConnection) u.openConnection();c.setRequestMethod("GET");c.setDoOutput(true);c.connect();(new File(FileUtils.getCachePath())).mkdirs();FileOutputStream f = new FileOutputStream(new File(file));InputStream in = c.getInputStream();


之前一直使用的这套代码下载图片.但是今天主管告诉我应用在4.0上出现问题. 查看代码后是图片下载失败的连锁反应.

在4.0上

c.getInputStream();

会报 java.io.FileNotFoundException

解决办法

//    注释掉改行.   c.setDoOutput(true);


http://comments.gmane.org/gmane.comp.handhelds.android.devel/195330

更多相关文章

  1. Android之十三图片2D翻转
  2. android webview实现唤起qq临时会话
  3. 在Eclipse 中关联android sdk 源代码
  4. Android的Location功能代码
  5. android http通信——HttpURLConntection
  6. Android(安卓)Studio配置Android(安卓)annotation(注解)
  7. Android腾讯微薄客户端开发十四:首页menu菜单
  8. 操作内存卡的常用代码
  9. Android(安卓)Studio使用AIDL时无法找到自定义的类

随机推荐

  1. AndEngine添加多个动画精灵的方法
  2. android 实现序列化 浅析一
  3. Beginning Android(安卓)Development
  4. Android(安卓)的网络编程(8)-文件上传功
  5. android GPS定位代码
  6. 使用android自带的SwipeRefreshLayout实
  7. Android适配器之---SimpleCursorAdapter
  8. 文件对应
  9. android studio 54 下载进度条
  10. android Preference Demo