Drawable.createFromStream and URL connection
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.graphics.drawable.Drawable;
public class NetworkUtil {
public static Drawable getDrawableFromUrl(String url, String src_name) {
try {
return Drawable.createFromStream(
((InputStream) new URL(url).getContent()), src_name);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
Related examples in the same category