1

I need a way to plot realtime data on a graph without blocking the UI thread. Reading several posts and articles I have understood that threads aren't the best choice to perform long works (it's an indeterminate update so it could take more than 3-4 minutes). So, what should I use? Thank You in advance.

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
gymni f
  • 398
  • 2
  • 14

1 Answers1

1

If your long task will run while your Activity is running, then you can use an AsyncTask. Else you can use a Service

antonio
  • 18,044
  • 4
  • 45
  • 61
  • I think I will use a Service but how can I access to the UI thread from the service to update the chart? Bcause I have also read that views should be managed in the UI thread while other computations should be done in a separate thread or in this case in a service – gymni f Jun 20 '16 at 20:48
  • You can start an Activity from a Service http://stackoverflow.com/questions/3456034/how-to-start-an-activity-from-a-service – antonio Jun 20 '16 at 20:55