0

Possible Duplicate:
Android: automatically choose debug/release Maps api key?

I use MapView in my application, so I have to use different api keys for Google maps. Key is defined in xml file (android:apiKey). Is there any way to use conditions there - so, if file is generated for testing (debug mode), then test key is used; if it is Release file, then release key is used.

Community
  • 1
  • 1
LA_
  • 19,823
  • 58
  • 172
  • 308
  • Please use the search function: http://stackoverflow.com/questions/3029819/android-automatically-choose-debug-release-maps-api-key/3828864#3828864 – Blundell Jul 03 '11 at 22:10

1 Answers1

1

You could just create the MapView on the activity create and set the API key there based on if in debug or not. Then add it to the main view group.

The API key just has to be passed in the constructor

MapView myMap = new MapView(this, apiKey); viewGroup.addView(myMap);

Jack
  • 114
  • 1
  • 4