Reputation: 369
Hello there and happy new year 2013!!
I returned to my app after vacation, and now I want it to keep alive and hearing for updates!! Does anyone knows how to do so? I don't mean a complete answer, I mean like guidence, orientation!! Because I don't know how to start doing it!! And on the other hand, how do I send the updates from my PHP/PostgreSQL server? Has anyone did something like this before that could help me?
Thanks in advance!!
Upvotes: 0
Views: 213
Reputation: 8876
If you want to PUSH updates to your application, you can do so using GCM: http://developer.android.com/google/gcm/index.html
If you can simply have your application POLL for updates periodically, then you can use AlarmManager and an IntentService to have your application hit your PHP endpoint as needed.
The choice of which to use usually comes down to how timely the updates need to be and how often they are likely to occur (taking into account battery, network, and other resource usage and so on).
To get started with GCM using PHP check out: Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
And, here's a good example of AlarmManager/IntentService (and handling wake locks).
Upvotes: 1
Reputation: 31
If by update you mean and update in version that is a user has version 1 of your app but there is version 2 available then you could do it like this :
You could have a variable that would save the current app version, then every time the user starts the app you should connect to your server to check the most up to date version. You then can compare and show an alert if the user has a lower version than the one you currently have in your server.
Two important things here : Every time you update your app you should look for the value of the version variable and change it and you should have the current app version variable in your server updated as well
If you mean updates in the data then your best bet is to use the GCM service (Google Cloud Messaging)
Upvotes: 0
Reputation: 1304
My advice is to use GCM to send push messages to the device the app is running on, simply because the GCM service is always running and it will use less battery than polling.
As a side note: don´t send the actual data via push notifications, instead just send a notification that there is new data on the server. The app can then download the new data from the server.
Upvotes: 0