12-15-2009 09:28 PM
I use a method in my thread named callBack.
public void callback(final String data)
{
if (data.startsWith("Exception")) return;
byte[] dataArray = data.getBytes();
bitmap = EncodedImage.createEncodedImage(dataArray, 0,
dataArray.length);
/*
if (bitmap != null)
{
inform = "";
invalidate();
}*/
setImage(bitmap);
}When i use thread.run() it ok. But thread.start() can not display image and throw an exception at setImage line. Somebody know the reason? I confirmed the data is load success because i had printed the length of data and compare in two situation. They are same.
Solved! Go to Solution.
12-15-2009 10:05 PM
When you call Thread.run(), you are just executing the run() method using your own calling thread.
Whan you call Thread.start(), you are starting a separate thread.
You cannot access the UI from a non-event thread. So, from you non-even thread you must synchronize with the event lock, or place your work in the event queue for processing by your event thread.
See the API docs for UiApplication.invokeLater(). This is what would suggest for what you are trying to accomplish.
12-15-2009 10:06 PM
Year. I found a Thread similar : http://rim.lithium.com/t5/Java-Development/Threads
So resolved.