Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sense 'dev mode' possible?

 
Maneesh Godbole
Saloon Keeper
Posts: 11327
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on an Android app which needs to connect to a remote server for some data.
During development, I connect a real device via USB to test/run the app. Since the server side too is being simultaneously developed, I also run the server in my local environment for dev testing.

The server URL and other parameters have been defined as constants. I am wondering if there is some mechanism which will automatically if the app code being run is in dev mode, i.e. device is connected to laptop via USB, or any other mechanism, so I can achieve the following



GWT offers a very convenient GWT#isProdMode(). Considering both Android and GWT frameworks, I was wondering if there is something similar available in Android
 
Tim Moores
Bartender
Posts: 3129
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The approach I use is

isDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)

You might also want to use dev params when running in the emulator:

isEmulator = Build.FINGERPRINT.startsWith("generic")

A more elegant solution would be to keep all those parameters in separate properties files that would live in src/debug/res/values and src/release/res/values, respectively. Then Gradle does the work for you.
 
Maneesh Godbole
Saloon Keeper
Posts: 11327
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim. I will try it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic