Reputation: 841
I add a new Google Cloud Module to my Android Studio project to create a backend servlet that I build as a WAR and deploy to Jetty (or to Google Cloud). The WAR file name is <module-name>.war
(eg. backend.war). When deploying the WAR file to Jetty the servlet's URL is https://<server-fqdn>/<module-name>
. The Android client code has to HTTP POST to that URL. How do I get the servlet module name programmatically in the Android client code so it can hit the servlet? Even if I later change the servlet module name, I don't want to have to revise the Android client Java code to keep it synced with the backend servlet name.
Upvotes: 3
Views: 1848
Reputation: 83557
Module names are only available at compile time. You cannot get them programmatically at run time. Instead, you should will need a way to specify the URL in your code. One way to do this is to have a class with a public static final String
that is accessible by all code that needs to know the URL.
Upvotes: 2