I have a main class;
ClientPlayer extends Activity {
and a service
LotteryServer extends Service implements Runnable {
Generally we use this method(RunOnUiThread) when we try to update our UI from a working thread. but As you are Using Service Here, runOnMainThread
is seems inappropriate as per your situation.
Better to Use Handler here. Handler is an element associated to the thread where is created, you can post a runnable with your code to the Handler and that runnable will be executed in the thread where the Handler was created.
Create a Handler on your Service in his MainThread and post Runnables on it / send messages to it.