0

I made an android app but I want to be able to update certain values even after the client has the app running(let's say I've got x=5; in the code and in the new version I'd like to have x=10; instead), kind of like how the apps you download from the play store notify you of updates and you can install the latest version.

I can't see how this is possible while the app is installed locally on the mobile so I thought about the cloud solution. Is there another way to do it ? And how do apps like facebook and messenger send notifications to the user?

future engineer
  • 109
  • 1
  • 8
  • Why don't you use the playstore? – anti_gone Feb 19 '17 at 22:54
  • If you're aware of those future configuration changes before pushing your app to the store then you should implement some kind of runtime configuration pattern (or remote config) and one recommended way is to use GCM as a trigger to get those new configurations. If you cannot predict it, then just ship your new changes with your new apk release. – Anis LOUNIS aka AnixPasBesoin Feb 19 '17 at 22:55
  • @AnixPasBesoin I can only predict that there will be changes but not the exact areas that will be changed. And I'm not really going to push the app to the playstore mainly because it's a crowdsensing app that is meant to be used by people around my city to study their habits and other things so I plan to locally distribute it – future engineer Feb 19 '17 at 23:14
  • @AnixPasBesoin but during the study (while the users have the app running on their phones) I should be able to change certain detection parameters(example the interval between two successive activity recognitions) to get better results. In this case, what is the recommended approach ? – future engineer Feb 19 '17 at 23:14
  • If you're just changing values and not code, it's fine to push new updates with GCM. – Anis LOUNIS aka AnixPasBesoin Feb 19 '17 at 23:17
  • Thank you for your reply, I'll try doing just that. – future engineer Feb 19 '17 at 23:20
  • Then just make calls to your own API to get the paramters (I guess from your post this was also your initial idea?). You can use GCM to notify clients or ask for updates periodically (push vs. pull model). – anti_gone Feb 19 '17 at 23:21
  • @anti_gone yes I have tested different parameters while developing the app but I was wondering how to change them in the version that's already being used by the volunteers around my city. So after the app is developed, I somehow connect it with GCM ? – future engineer Feb 19 '17 at 23:28

1 Answers1

1

Assuming that you are talking about changing values, ie state of the app and not actually trying to download new code, you have a couple of options.

If this is the case then what you really want to do is to make your app aware that something needs to change. (This could be just a notification that there is a new version and that the user should download it from the play store)

There are a least two ways to the information to your app.

GCM is one option, but not the only option.

GCM is for "push" notifications, ie notifications that you want to send your app or user even if they are currently using your app. In order to use GCM you would need to host some sort of a server, which would send the notification when the server deems it is needed.

An other option would be to have your app "check in" with your server and download some content. The content could contain the values that need to be changed, or simply that the app should inform the user that he/she should take some further action to update something with respect to the app. This also would require that you host a server.

The second option is easier, mainly because in order to send your app messages via GCM, you pretty much have to be able to do the second option. The android platform provides many life cycle hooks which give you opportunities to "check in" with your server. For example during the onResume of an Activity might be a good place to "check in"

nPn
  • 16,254
  • 9
  • 35
  • 58