I’d like to pass an argument to the android emulator launched via Eclipse. This argument is a custom one that I would use to determine if the server’s address to connect to is either “localhost” or “myserverdomain.com”. This is because I don’t want to have two binaries, or two versions, of the same program, whenever I run the program in production or in local test environment.
In plain Java, I can use the command line arguments for that matter, and retrieve them in the main(), or also use the custom environment variables and retrieve them with System.getProperty().
I can’t find any similar feature in Android. Do you know any please ?
This is possible, although I haven’t tried to do it via Eclipse.
From the command-line you can use adb to launch a shell and run an application with parameters.
For example,
will start my activity with extras that I can extract from the bundle like so,