Reputation: 557
I'm devepling and android application that should connect to an application server.
What I'm asking about is, should I write the url of this application server statically inside the code or is there a way provided by android to dynamically change the url if needed ??
Taking into consideration that once the app is uploaded on play store, the application server should reserve the address and never change so as not to affect the android app.
I'm just asking about best practices in those situations.
Thanks all :)
Upvotes: 0
Views: 632
Reputation: 15476
You can write the URL of the redirect server in the code, and have that server redirect to different URLs as required. The redirect "server" in its simplest form can be just a text file stored on your company's website, for example.
Upvotes: 0
Reputation: 22527
It is best to consider that your server will be relocated in the future, because you never know. Unless you are willing to upgrade your application anytime it happens, dynamic configuration is the best approach.
Upvotes: 0
Reputation: 1899
Although that would be nice, it might not be worth the hassle. I think it's fine to code in the URLs as they are currently. If for some reason you change the endpoint, try and make it so you send an error saying that the user needs to update the app (and release a new version with the updated URLs). It's also a nice way of indirectly getting your users to update to the latest version so you don't have many to maintain!
Also, if your server moves, it's still not a problem, since you'll still be using the same domain name to point to your server!
(This is assuming that it's still the same domain name, and it's just the endpoint changing, and you don't need to reuse the previous endpoint for something else. Yeah, quite a few assumptions :) )
Upvotes: 2