I have an app that communicates with a server (also mine) over HTTP.
When I'm developing on the emulator, I'd like to be able to talk to my
server via localhost, which I can do by using the IP 10.0.2.2.  When
I'm developing on a device, I'd like to be able to talk to my server
via some other IP, say 192.168.1.100 as an example.  Currently, when I
want to switch between emulator and device development, I change a
line of code in my app that looks something like:

final String httpServer = "10.0.2.2";
//final String httpServer = "192.168.1.100";

Being a lazy programmer, I don't want to have to do this by hand.  Is
there some way for me to specify different run environments or (insert
something really nifty) to get this behavior?  While developing for
iOS, I could do this by having two targets, each of which would pass
in different compile-time flags that I could use in my code to do
this, similar to:

#ifdef device
#define httpServer "192.168.1.100"
#else
#define httpServer "10.0.2.2"
#endif

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to