~ TreKing wrote: > On Fri, Apr 9, 2010 at 5:20 PM, Tom Opgenorth <[email protected] > <mailto:[email protected]>> wrote: > > Is there a better way to manage this? > > > Sure. > > First determine which key you need based on the "debuggable" attribute > in your manifest file, which you can check dynamically via an > ApplicationInfo, which you can get via the PackageManager: > http://developer.android.com/intl/de/reference/android/content/pm/ApplicationInfo.html#FLAG_DEBUGGABLE > > String key = isDebug() ? DEBUG_KEY : RELEASE_KEY; > > Then use the map view constructor that takes the API key to pass it > dynamically instead of specifying it in the layout (this means you also > have to add it to the main layout programmatically). > > mMapView = new MapView(this, key); > // Add map view to layout ... > > Just remember to change that debuggable attribute, which you should be > doing before release, and you should be golden.
Another related option would be to have two copies of the layout containing the MapView, one with the debug key and one with the production key, and use isDebug() to choose which one to load. You could even only maintain one copy and modify your build process to generate the other one on each compile. The advantage here is in minimizing the amount of layout-related Java code, which can get icky for dealing with landscape vs. portrait, multiple screen sizes, etc. What would be cool, but doesn't exist AFAIK, is a resource set qualifier for debug mode. The you could have values-debug/strings.xml with the debug key and values/strings.xml with the production key, and just reference the string resource in the layout file. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

