ImageViews not loading remote images on device

You must Login before you can answer or comment on any questions.

Hi guys - I'm trying to get my head around this one and am having an issue with the ImageView control.

This code fails to load the image on the device (Android OS: 2.3.6), but works in the emulator (designed for Android OS 2.3.3):

var window = Ti.UI.createWindow({ title: 'blah' });
 
window.add(Titanium.UI.createImageView({
    width: 150,
    image: 'http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png'
}));
 
window.open();
Changing the image source to be 'images/options.png' works as it should.

DDMS reports:

[D] Retrying bitmap decode: 5/5
[W] Bitmap bounds could not be determined.  If bitmap is loaded, it won't be scaled.
[E] Max retries reached, giving up decoding image source
I am using SDK 1.7.5 in Titanium Studio 1.0.6

Am I missing something?

— asked 1 year ago by fatty miller
5 Comments
  • i've suffered from the same issue...the problem is that the image u r fetching is higher in the memory size than the memory size alloted to imageview.U can overcome this issue by compressing ur image during u fetch if, by making slight changes in the imageView property. If u need some test code then i can post.hope this suggestion will help u.

    — commented 1 year ago by Gagan Tiwari

  • Hi its running on my android emulator. As Gagan pointed out, it can be the size of the image thats causing the issue. Don't use heavy image files.

    — commented 1 year ago by Zarir Bhesania

  • Thanks guys, I've done another quick Google, and came up with this - Do we know what the max file size is allowed to be? @gagan: would I be able to get you to show me some code that would allow me to compress the image down on request, please?

    — commented 1 year ago by fatty miller

  • Show 2 more comments

3 Answers

Turns out the answer was to delete the [package name]/remote-image-cache directory from the sdcard of the device.

Not sure why this was needed, though. Perhaps it had reached it's allowance of file size or something? There were quite a few image cache files in there.

Thanks for your help on this.

i've suffered from the same issue...the problem is that the image u r fetching is higher in the memory size than the memory size alloted to imageview.U can overcome this issue by compressing ur image during u fetch if, by making slight changes in the imageView property. If u need some test code then i can post.hope this suggestion will help u.

— answered 1 year ago by Gagan Tiwari
answer permalink
1 Comment
  • I wish it was, but this is not the answer. One of my later comments notes that it doesn't matter what the image size or dimensions are as not even an 8x33 image loaded. As I posted in another question here it seems to depend on the source of the image..?

    — commented 1 year ago by fatty miller

use following:

var window = Ti.UI.createWindow({ title: 'blah' });
var imageView = Titanium.UI.createImageView({
    top:0,
    left: 0,
    right: 0
})
window.add(imageView);
window.open();
 
var URL = 'http://antoniofarinha.com/blog/wp-content/uploads/2009/08/barney-stinson.jpg'
 
var c = Titanium.Network.createHTTPClient();
c.setTimeout(10000);
c.onload = function() {
    if(c.status == 200) {
        imageView.image = this.responseData;
    }
}
 
c.open('GET', URL);
c.send();

Your Answer

Think you can help? Login to answer this question!