In an android service I have created thread(s) for doing some background task.
I have a situation where a thread needs to post certain task on main thread\'s message
There is another simple way, if you don't have an access to the Context.
1). Create a handler from the main looper:
Handler uiHandler = new Handler(Looper.getMainLooper());
2). Implement a Runnable interface:
Runnable runnable = new Runnable() { // your code here }
3). Post your Runnable to the uiHandler:
uiHandler.post(runnable);
That's all ;-) Have fun with threads, but don't forget to synchronize them.