2

What is the recommended approach/pattern for exchanging big chunks of data between activities and remote services? The data I want activities to receive is non primitive and is contained in HashMaps of <Object, List<OtherObject>>. Parcelable seems to be complete overkill to me, is there another way? Oh, and this exchange takes place every 4 sec. on average.

Maybe Julius
  • 1,203
  • 2
  • 13
  • 16
  • Why is the service remote? – CommonsWare Jun 12 '13 at 22:33
  • What format is the data in that comes from your service? – James andresakis Jun 12 '13 at 22:37
  • The service is remote because I want it to run on different thread since it does quite some calculations. The data is actually wifi signal strengths (their history and fingerprints generated from their histories based on various algorithms and camparisons to fingerprints in the database)... basically I'm trying to determine my position based on wifi data that I collect. And I need to graph the data, otherwise it's hard to understand it :) – Maybe Julius Jun 13 '13 at 10:17

2 Answers2

1

The most efficient way of exchanging big chunks of data between processes in Android is ashmem. There is a Java wrapper for ashmem - MemoryFile, but it is rather confusing - you need to pass parcelable file descriptor between processes, please refer to this SO post

Then you can just serialize your data into that "file" and deserialize it on the other side.

Community
  • 1
  • 1
msh
  • 2,700
  • 1
  • 17
  • 23
0

Do you need to refresh the data every 4 seconds? That seems ambitious to me. In any event, you have to consider what form you're going to store it in. You need to focus on efficiency; download as little "meta-data" as possible and cache it.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18