Retrieve image from URL, checked all info but cannot get it.

All your problems with Audio, Video and Images.

Retrieve image from URL, checked all info but cannot get it.

Postby andykalbvleesch » Tue Jan 20, 2009 3:07 pm

Hi All,

Call me insane but I just cannot get this to wrok. I have an image on my server, offcourse I can see this image in my webbrowser... In Androidmanifest I have the permission internet, in my main.xml I have the imageview advertisement, I have all the right classes in my import. What is wrong with this code ??? Please anybody help I go nuts over this... I allways get the IOexception...

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView chart = (ImageView) findViewById(R.id.advertisement);
Bitmap bmImg;
try {
URL chartUrl = new URL("http://www.freshsolutions.nl/android/advertenties/fiat.png");
HttpURLConnection conn= (HttpURLConnection)chartUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
chart.setImageBitmap(bmImg);

} catch (IOException e) {
/* Reset to Default image on any error. */
}
}
andykalbvleesch
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jan 20, 2009 2:36 pm

Top

Postby MrSnowflake » Tue Jan 20, 2009 3:14 pm

shouldn't you do conn.get() or something like that? (I'm guessing here, so you know)
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Indeed very stupid rights issue....

Postby andykalbvleesch » Tue Jan 20, 2009 4:34 pm

Make sure you do have the rights set well in Manifest... I made a mistake and I saw it on the emulator when checking the rights for the application...
andykalbvleesch
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jan 20, 2009 2:36 pm

Re: Indeed very stupid rights issue....

Postby MrSnowflake » Tue Jan 20, 2009 4:49 pm

andykalbvleesch wrote:Make sure you do have the rights set well in Manifest... I made a mistake and I saw it on the emulator when checking the rights for the application...
If that was the case, it wouldn't have thrown the IOException. (Though, the permission could still be wrong, but not with this particular problem)
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 15 guests