I want to provide configuration settings into my android app without putting them in code, e.g. an API url (so that i can replace them post-build later). Where do I put this (should it go into AndroidManifest.xml?), and how can I retrieve it?
Asked
Active
Viewed 116 times
0
-
Have you done any research before coming here to post? https://stackoverflow.com/questions/28794656/where-to-put-the-api-key-resources-meta-data-in-manifest-or-static-variable – pkanev Mar 09 '18 at 08:48
-
Great, but how do I access this within Nativescript? – Bart van den Burg Mar 09 '18 at 09:27
1 Answers
0
Ok, figured it out. Had to put the meta-data key in Application (not Activity) and then access it as such:
const ai = app.android.context.getPackageManager().getApplicationInfo(app.android.context.getPackageName(), 128);
this.apiUrl = ai.metaData.get("apiUrl");

Bart van den Burg
- 2,166
- 4
- 25
- 42