i'm a new Android developer and I'm developing an application that display image from an url adress. It works fine in wifi but doesn't work in 3g. Here's the code :
private void downloadImage(String urlPar, boolean imageSuivant) {
try {
URL urlImage = new URL(urlPar);
HttpURLConnection connection = (HttpURLConnection) urlImage.openConnection();
InputStream inputStream = connection.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
image.setImageBitmap(bitmap);
connection.disconnect();
inputStream.close();
} catch (MalformedURLException e) {
if(imageSuivant==true)
imageSuivante();
else
imagePrecedente();
e.printStackTrace();
} catch (IOException e) {
if(imageSuivant==true)
imageSuivante();
else
imagePrecedente();
e.printStackTrace();
}
}