Android Bitmap Load getBitmapFromInternet(String strName)

Here you can find the source of getBitmapFromInternet(String strName)

Description

get Bitmap From Internet

License

Open Source License

Declaration

public static Bitmap getBitmapFromInternet(String strName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.InputStream;

import java.net.HttpURLConnection;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {

    public static Bitmap getBitmapFromInternet(String strName) {

        try {//from   w w w. j  a  va  2  s  .co  m
            URL url = new URL(strName);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream input = connection.getInputStream();
            Bitmap myBitmap = BitmapFactory.decodeStream(input);
            return myBitmap;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}

Related

  1. getResizedBitmap(Uri imageUri, Activity activity)
  2. downSampleBitmap(Uri uri, Activity act, Boolean needRotate)
  3. getBitmap(Context context, int resId)
  4. getBitmap(String photoId)
  5. getBitmapFromAsset(String strName, Context context)
  6. getBitmapFromUri(Context ctxt, Uri selectedImageURI)
  7. getBitmapFromUrl(String url)
  8. loadBitmapFromFile(String fileNameWithPath)
  9. downloadBitmap(URI uri)