private void picture() { new Thread(){ @Override public void run() { super.run(); URL url=null; HttpURLConnection huc=null; InputStream is=null; Bitmap bm= null; try { url=new URL("https://www.baidu.com/img/bd_logo1.png"); huc= (HttpURLConnection) url.openConnection(); huc.connect(); if (huc.getResponseCode()==200){ is=huc.getInputStream(); bm = BitmapFactory.decodeStream(is); final Bitmap finalBm = bm; runOnUiThread(new Runnable() { @Override public void run() { iv.setImageBitmap(finalBm); } }); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }.start(); }
GEt获取图片
最新推荐文章于 2022-04-17 14:51:42 发布