标签:des android http io os java for sp on
============问题描述============
System.out.println("before bm = " + bm); String imageUrl1 = "http://10.0.2.2:8080/BBStuServlet/test01_upload_1.jpg"; bm = NetTool.downlodBitmap(imageUrl1); map2.put("image", bm); System.out.println("after bm = " + bm);
image.setImageBitmap(bm);
/* * 从指定url下载图片 */ public static Bitmap downlodBitmap(String url) { URL myFileUrl = null; Bitmap bitmap = null; try { myFileUrl = new URL(url); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) myFileUrl .openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
============解决方案1============
============解决方案2============
标签:des android http io os java for sp on
原文地址:http://www.cnblogs.com/liangxieliang56/p/4035771.html