I trying read a external imagen but I've the error
"android.os.NetworkOnMainThreadException" and "http.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)"
OnCreate
imageView = (ImageView) findViewById(R.id.image_view);
downloadFile(imageHttpAddress);
Function downloadFile
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();
}
}