Working with sockets usually requires a separate thread. As I understand it, this is especially critical in Android OS. The IdTCPServerExecute method should not directly work with the GUI of the main thread and use global variables. To do this, you need a synchronization mechanism, for example, critical sections. How Indy works in Android on FPC never tested.