I am developing an Android application where I need to receive data (news) from a server. I know how to do this using streams and / or AsyncTasks, etc., but since I need data in widgets, and because I would like to know which path is preferable in general, I thought I would ask you guys.
I thought of a few specific implementations, namely:
1) In principle, create a class that uses Threads to retrieve data from which I access both from my usual actions and from the widget. Perhaps cache information for future reference.
2) Using a service that I can request from my widget and application. This service does not have to work all the time, but it can be started when I need data, and it stops when it retrieves and returns data. This service can be launched periodically to update data for the widget or something like that.
There are probably many ways to solve this problem, so I would like to hear what you think is a good approach to this problem.
Thanks in advance, Erik
Erik
source share