04-20-2010 06:57 AM - edited 04-20-2010 07:01 AM
public class getimage extends UiApplication {
public static void main(String[] args) {
getimage theApp = new getimage();
theApp.enterEventDispatcher();
}//main
getimage()
{
try {
pushScreen(new NewScreen() );
} catch (IOException e) {
e.printStackTrace();
} } }
final class NewScreen extends MainScreen
{
Field imageField;
class RemindTask extends TimerTask {
public void run() {
imageField = new WebBitmapField(url);
}//run
}//Task
public NewScreen() throws IOException
{
super();
try
{
add(imageField);
Timer timer = new Timer();
timer.schedule (new RemindTask(),0, 1000);
} catch(Exception e){}
} }}
i just checked image on simulator it was perfect
and now.i want to re-download and re-paint image every 2 seconds
because server is webcam that sending jpg
but this source is not working
i only saw the white screen
what wrong with this source ?
04-20-2010 07:14 AM
Hi!
This WebBitmapField, is it from Coderholic - Blackberry WebBitmapField?
try this code:
class RemindTask extends TimerTask {
public void run() {
WebBitmapField newImageField = new WebBitmapField(url);
replace(imageField, newImageField);
imageField = newImageField;
}//run
}//Task
My opinion is you cannot afford 2 seconds even with fast wifi.
What you can try to do is download not the full image but some kind of offset, difference between current image and previous.
04-20-2010 07:36 AM
yes ,it is Coderholic - Blackberry WebBitmapField
unfortunately, it doesn't work
i can see only white screen;; T T
04-20-2010 09:23 AM
So have you checked that the code is downloading an image on the real device.
Please review this Thread, especially the Simulator section and Required Reading, to understand that as far a network test is concerned, code working on the SImulator will probably not work on the device.
Also for this application, I think the only way you are going to get an image to your device in 2 seconds is via WiFi, so that is the connection method I would use (exclusively). And in this case, I would not use a TimerTask. Sorry for giving you incorrect advice on the other Thread, but I would start a download Thread, that continually downloads the image, then stalls for 2 seconds between downloads.