public class Main extends Activity {
private ImageView imageView;
private Bitmap loadedImage;
private String imageHttpAddress = "http://jonsegador.com/wp-content/apezz.png";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) findViewById(R.id.image_view);
downloadFile(imageHttpAddress);
}
void downloadFile(String imageHttpAddress) {
URL imageUrl = null;
try {
imageUrl = new URL(imageHttpAddress);
HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
conn.connect();
loadedImage = BitmapFactory.decodeStream(conn.getInputStream());
imageView.setImageBitmap(loadedImage);
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Error cargando la imagen: "+e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}