How to update UI from a service that has threads?
Create a thread in the Service class and directly access UI components of your activity
Since updating UI from other thread directly is not possible, communicate with Main UI thread for the UI updates
Use Intent Service
Either use option1 or option 2
Android follows singled threaded UI model, i.e other threads should not touch UI with out taking permission of Main UI thread. If other threads wants to touch UI, communicate it to Main thread. Many ways are there to achieve it, use 1. RunOnUiThread() 2. use Handlers to communicate to main thread 3. Use AsyncTask and update ui from onPre or onPost or onProgress ..
Back To Top