hi,
i tried to create a simple thread which updates every 5 seconds the status auf the batterie.
now I have this little piece of code:
Code:
TimerTask worker = new TimerTask();
worker.run();
/*
...
*/
final class TimerTask extends Thread {
LabelField label1 = new LabelField("Batteriestand: wird ermittelt...");
public TimerTask()
{
}
public void run() {
add(label1);
int temp = DeviceInfo.getBatteryLevel();
String a;
a = "" + temp;
this.label1.setText("Batteriestand: "+a);
while(true) {
try {
Thread.sleep(5000);
int temp2 = DeviceInfo.getBatteryLevel();
String b;
b = "" + temp2;
System.out.println("Batteriestand: "+b);
this.label1.setText("Batteriestand: "+b);
} catch( InterruptedException e ) {
System.out.println(e.toString());
System.err.println(e.toString());
}
}
}
} i know it isn't the perfect code, but i'm still a beginner ;)
when I try this little "program" on the simulator it works fine, but when I try this one on my BlackBerry I get an error-message by the debugger:
Quote:
|
Uncaught exception thrown - Cannot determine object class. Missing debug information.
|
when I comment the line
this.label1.setText("Batteriestand: "+b); then the debugger does not throw out an error.
so how can I update the LabelField Text without an exception error?
hibbert