2

Using android sdk 2.3. How can I synchronously update the UI from a service. I just need to update a text view in an Activity but it has to be synchronous, so my worker thread needs to stop for a bit. On iOS there is performSelectorOnMainThread waitUnitDone

I can't find a waitUntil done on Android using runOnUIThread etc

Thanks

tech74
  • 301
  • 5
  • 20
  • Have you done some research? There are plenty of similar questions on StackOverflow: http://stackoverflow.com/questions/3197335/restful-api-service/3197456#3197456, http://stackoverflow.com/questions/2621395/more-efficient-way-of-updating-ui-from-service-than-intents etc. – Amokrane Chentir May 05 '12 at 10:10

1 Answers1

-1

there are multiple ways to update UI in android after completing task in worker thread. you can go for Handler. Other way to do this efficiently is by using AsyncTask.
runOnUithread is also one of the option.

N-JOY
  • 10,344
  • 7
  • 51
  • 69
  • I'm sorry to do some necromancy, but I have the same problem. Your answer doesn't fit the problem. The worker thread sends a request to UI thread, then has to wait until UI was changed. Your answer tells us, how to do an UI update, after worker is finished. – EarlGrey Jul 23 '14 at 08:58
  • This answer was not intended to suit your requirement. This answer was a reply to the above question. – N-JOY Jul 24 '14 at 12:44
  • Maybe I'm missunderstanding the question, but the creator seemed to have the same problem as I had. That's why I wrote 'I have the same problem'. And for that, you answer the other way round as asked. – EarlGrey Jul 24 '14 at 12:57