I want to have a final
variable that is true
when I run the Debug version of my project, and false
when I run the Run version. I understand I can do this with build configurations but have no idea how to set this up in Eclipse. There don't appear to be any tutorials or questions on Stack Exchange regarding defining variables specifically.
I'm compiling Java in Eclipse Classic 4.2, creating an Android app using the ADT plugin.
EDIT: Per @Xavi, I set up the following:
try {
String line = null;
java.lang.Process p = Runtime.getRuntime().exec("getprop debugging");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
Log.d("Property:", line); //<-- Parse data here.
}
input.close();
} catch (IOException e) {
e.printStackTrace();
}
And in the "Additional Emulator Command Line Options" field of the Target tab of the Debug Configurations window, I've entered:
-prop debugging=true
Unfortunately it looks like this only works in emulator mode. It doesn't print anything when running on my phone. (It works fine running on an emulator.)
EDIT: Per @Sharks I found some links that seem relevant, but I don't know how to apply them to my situation: