Images Displaying In List On Emulator But Not On Real Device

65 views
Skip to first unread message

Keen Student

unread,
Oct 25, 2013, 10:01:25 AM10/25/13
to codenameone...@googlegroups.com
I have a j2me application that displays images and text in a list.
The images are displayed using the ImageDownLoadService.

The application runs perfectly on the simulator in netbeans,
and the images are all displayed.

The issue is that when i installed the application on a NOKIA 205 device,
the images where not being displayed.

How can i resolve this. Thanks.

Shai Almog

unread,
Oct 25, 2013, 12:37:13 PM10/25/13
to codenameone...@googlegroups.com
Its possible that there is no space to display these images in the low resolution with the given layout so they are cropped out.
Did you run this on the feature phone simulator?

Keen Student

unread,
Oct 25, 2013, 1:25:39 PM10/25/13
to codenameone...@googlegroups.com
Yes i tested it on the Feature phone simulator. Do you recommend that i reduce the size of the image?....i am currently resizing it to 48x48

Shai Almog

unread,
Oct 26, 2013, 3:09:44 AM10/26/13
to codenameone...@googlegroups.com
How are you resizing it?
What is the original image size?
If instead of setting an image you do something like Image.create(48, 48, 0xffff0000) would that work on the device (should create a red rectangle).

Keen Student

unread,
Oct 28, 2013, 4:16:04 AM10/28/13
to codenameone...@googlegroups.com
This is the code i am using to resize it :
 ImageDownloadService.createImageToStorage(url,list, index, "photo","new data"+id,new Dimension(48, 48));
 The original size it 118x150 px.
I am calling this method from a ListRenderer. So how will i utlize your suggestion.( The image is being downloaded from a url).  Thanks

Shai Almog

unread,
Oct 28, 2013, 12:06:29 PM10/28/13
to codenameone...@googlegroups.com
You should have mentioned renderer sooner.
ImageDownloadService cannot work on a renderer since it is stateless. If it shows something it is purely a race condition.
I suggest searching this forum for ImageDownloadService List where you will find multiple detailed discussions and examples.

Keen Student

unread,
Oct 29, 2013, 3:51:06 AM10/29/13
to codenameone...@googlegroups.com
I had read previous threads on the forum and was able to study the facebook sample. The code there was throwing errors...but when i used a try...catch block to begin downloading...it worked on all the emulators. This is the code excerpt  i used for my renderer:
private Label photo = new Label("");
...............
public ItemsRenderer() {
setLayout(new BorderLayout());
addComponent(BorderLayout.WEST, photo);
....................
 public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        Hashtable v = (Hashtable) value;
........................
Image indu= null;
       try {
           indu=(Image)v.get("photo");}
       catch(Exception ec)
                   {
        ImageDownloadService.createImageToStorage(url,list, index, "photo","new data"+id,new Dimension(48,48));
            }
        photo.setIcon(indu);



The above code works on the emulator but not on real devices. 

Shai Almog

unread,
Oct 29, 2013, 3:05:47 PM10/29/13
to codenameone...@googlegroups.com
The facebook demo renderer works, I suggest you look at Eric's tutorial as well.
I don't see what you are using the image download in an exception catch block, why would a hashtable get throw an exception.

Keen Student

unread,
Oct 30, 2013, 3:55:59 AM10/30/13
to codenameone...@googlegroups.com
Got it to work..modified some code from a discussion i saw on the forum
Reply all
Reply to author
Forward
0 new messages