vijay
1/21/2015 - 7:51 AM

Convert Image URL to Bitmap

Convert Image URL to Bitmap

public static Bitmap getBitmapFromURL(String src) {
		try {

      //uncomment below line in image name have spaces.
			//src = src.replaceAll(" ", "%20");
			
			URL url = new URL(src);

			HttpURLConnection connection = (HttpURLConnection) url
					.openConnection();
			connection.setDoInput(true);
			connection.connect();
			InputStream input = connection.getInputStream();
			Bitmap myBitmap = BitmapFactory.decodeStream(input);
			return myBitmap;
		} catch (Exception e) {
			Log.d("vk21", e.toString());
			return null;
		}
	}