2

I am designing an Android application that needs to receive constantly changing information (so the update interval must be very small).

Right now I am reading this information by consuming a REST WebService, but I am wondering if this is the best approach, regarding the battery drainage. This application would have to refresh the data being shown very often (specifically GPS data read from another system).

I have been reading about Google Cloud Messaging but I didn't find any comparisons between the two approaches.. Theoretically both approaches fit my needs since the data changes so frequently that it doesn't really matter whether it is updated by request or on a timer..

So my question is: Should I stick with WebServices or shift to GCM? Is there another battery-efficient solution?

Thanks in advance!

pteixeira
  • 1,617
  • 3
  • 24
  • 40

2 Answers2

2

GCM utilises a connection that is already there - using this over your current polling methods is definitely recommended and will be much friendlier with the battery.

Rawkode
  • 21,990
  • 5
  • 38
  • 45
2

Think about it, in your case GCM will send you a notification to let you know you need to refresh data so instead of just calling refresh you have: receive the notification, process it and then call refresh. So if you need to refresh so often, like just say each minute and it's constant just skip the notification. I would set a recurring alarm, get the intent in a BroadcastReceiver and trigger an IntentService for the refresh

MariusBudin
  • 1,277
  • 1
  • 10
  • 21