How can I display image in an ImageView in android from a URL (from the internet)?
First hit the image link,then you will get the image as byte array.Now just decode the byte array to bitmap image.Lets take a look:
package Image.Read.a;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import android.graphics.BitmapFactory;
public class Connecetion1
{
public void setNetwork()
{
try
{
URL url = new URL("http://3.bp.blogspot.com/_9UYLMDqrnnE/S4UgSrTt8LI/AAAAAAAADxI/drlWsmQ8HW0/s400/sachin_tendulkar_double_century.jpg");
URLConnection connection=url.openConnection();
HttpURLConnection HCon=(HttpURLConnection)connection;
int ResCode=HCon.getResponseCode();
System.out.println("Responce Code is = "+ResCode);
if(ResCode==HttpURLConnection.HTTP_OK)
{
InputStream ins=((URLConnection)HCon).getInputStream();
Data.StoreImg=BitmapFactory.decodeStream(ins);
}
}
catch (MalformedURLException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
You can get the full tutorial from http://www.androidcookers.blogspot.com/2011/06/retrieve-image-from-internet.html