Android provides quiet service calls all the time

I'm developing an application that updates the UI every minute after getting data from the web service. I know we can call asynctask every time to get data, but it seems strange. There is another way to get data in the background service and receive its broadcast in the activity. However, if the database does not change, So we are using resources. What methods can we check whether there are changes in the database and get the data

resolvent:

I think you should use push instead of pull data every time. Implement GCM push in your application. If there is any change in data, the information you are interested in the server will send a push about the change

Your application will then receive information about the changes in the broadcast receiver in the way you want. Your application can then make API calls and get the actual data

Here are more details about GCM: https://developers.google.com/cloud-messaging/

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>