Advertisement
NgThanhPhuc

Android_getBitmapFromURL

May 12th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. // tai hinh anh ve --> bitmap
  2. public static Bitmap getBitmapFromURL(String src) {
  3. try {
  4. URL url = new URL(src);
  5. HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  6. connection.setDoInput(true);
  7. connection.connect();
  8. InputStream input = connection.getInputStream();
  9. Bitmap myBitmap = BitmapFactory.decodeStream(input);
  10. return myBitmap;
  11. } catch (IOException e) {
  12. e.printStackTrace();
  13. return null;
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement