質問

What is the best way to download updated in JSON format information, I am using a service in android which every 4 seconds will be downloading a JSON, and then this information is displayed in a listview but my problem is that this service consumes me much battery and mobile data plan. What is the best way to only download new data from JSON. How to download information to only if there really is a new data or update data?

役に立ちましたか?

解決

Google Cloud Messaging is probably the best option -- it was created for this kind of scenario (to avoid constant/repeated polling of a server to check for new/updated data).

Another option that would save you some bandwidth would be to check the last modified field and only download if newer (connection.getHeaderField("Last-Modified")). This will save you from re-downloading the same data over and over if it hasn't changed, but it will still use up lots of battery, because you have to keep the radio powered up to do your polling. So, GCM is a better choice.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top