• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Sense 'dev mode' possible?

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. I will try it out.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic