Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.drawable.BitmapDrawable;

import java.net.HttpURLConnection;

import java.net.URL;

public class Main {
    /**
     * 
     * @param imgURL
     * @return
     */
    public static BitmapDrawable downloadBitmapDrawable(String imgURL) {
        BitmapDrawable icon = null;
        try {
            URL url = new URL(imgURL);
            HttpURLConnection hc = (HttpURLConnection) url.openConnection();
            icon = new BitmapDrawable(hc.getInputStream());
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return icon;
    }
}