If I understand Android manual, BroadcastReceiver
is treated as stateless entity, so I should keep a service which will serve as data container (those are my conclusions).
As per each request for data access I should execute startService
(?) -- I can pass this way data to service, but how to get data back?
I mean in recommended way? I could think of passing "out" data, and service on completion would change it, so when startService
returns I could check the data I sent in order to retrieve the result.
If I understand Android manual, BroadcastReceiver is treated as stateless entity, so I should keep a service which will serve as data container (those are my conclusions).
Having a service around solely to hold onto data will make your users dislike you, and is no guarantee that the data will stick around anyway. The user and the OS can and will get rid of your process whenever they wish.
Please use files (e.g., database, SharedPreferences
) for holding data that needs to survive between process invocations.
I wouldn't use a service for this, SharedPreferences are very useful for storing some key/value pair data.