Hi,
I am creating an appication for video recording and I overlayed the video preview with labels txtStatus and txtTime.
The camera button starts/stops the timer which periodically calls the UpdateGUI method. Running the debug I can see the timer is working - it calls updateGUI method every second but the method doesn't update the controls.
I would really appreciate if I could get any hint on how to fix this issue.
Here is the code:
This is the method which activates the timer:
private void startTimer()
{
updateTimer = new Timer("TimerUpdate");
updateTimer.scheduleAtFixedRate(new TimerTask(){
public void run(){
settings.IncreaseRecordingTime();
updateGUI();
}
}, 0, 1000);
}
This is the updateGUI method:
private void updateGUI()
{
setStatusLabel();
String strTime = settings.GetTimerString(); //strTime changes every second (it works as expected)
txtTimer.setText(strTime);//the text doesn't change!
}
And this is the method which is called when the button is pressed:
private boolean onCaptureButton()
{
settings.CaptureAction();
videoPreview.setFrameCallback(settings);
updateGUI();//here the function updateGUI() works as expected - it changes the txtStatus text from "Preview" to "Recording"
setTimer();
return false;
}
I added some comments as well (don't know why updateGUI() works when it is called at onCaptureButton() method and doesn't work when called inside the timer method).