TTimer in delphi cause wrong thread exception when create a instance form in Android

  

my problem is i have a timer to display a form in time. In iOS it work well with my code, but in android it’s display an exception : android.view.viewrootimpl$calledfromwrongthreadexception only the original thread that created a view hierarchy can touch its views. But i thought timer on delphi will be run under main thread? I also put a TThread.Synchronize to check but it’s still the same exception. Any idea how to handle this. Thanks.

Here is my code. I start application with Form1, have the timer inside it:

timer := TTimer.create(nil);
timer.Interval := time
timer.OnTimer := DoScreenTimerEvent;

In DoScreenTimerEvent function in Form1 will show the Form2( this is a screensaver in my application):

Form2:= TForm2.create(nil);
Form2.Show;// raised exception here.

The problem is i have many form like Form3, Form4, etc… the Form2 will display after interval i had putted in the timer, whenever i’m in Form3, or 4… In iOS, it work perfectly but in android i got above exception.

Comments are closed.