• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Extending Thread

  • Thread starter Thread starter Deleted User
  • Start date Start date
D

Deleted User

Guest
Hi,

I have a class I've created that extends Thread. This class calls a web service that returns a bunch of data. I'd to populate a member variable back in my Activity with this data as well as update the list on the Activity with this data. How can I achieve this? I've found an example to do it if you define the thread in the Activity class, but I have a separate file that extends Thread here. Could I get some assistance?

Thank you
 
You can only update GUI widgets in the GUI thread. So your other non-GUI thread needs to send a message back to the GUI thread through a Handler.

You create a Handler in the GUI thread and pass it to your non-GUI thread. Your non-GUI thread can then send messages back to the GUI thread, and that can respond by updating widgets as required.

See the following:

Common Tasks and How to Do Them in Android | Android Developers

Rise Software Online: Tutorials for developers - Advanced's blog: Threading using AsyncTask and Thread/Handler

Creating Dialogs | Android Developers
(Look down the page for Handler)
 
Back
Top Bottom