How to work with an image using url in android?

android

Solution

You can use the following code to download an image:

URLConnection connection = uri.toURL().openConnection();
connection.connect();
InputStream is = connection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 8 * 1024);
Bitmap bmp = BitmapFactory.decodeStream(bis);
bis.close();
is.close(); 

Requires the following permission in AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

Problem

Given a Url for an image, I want to downoload it and paste it onto my canvas in android. How do I retrieve the image into my app ? Please help. Thanks, de costo.

Original source