Is it possible to use conditions at xml files? [duplicate]
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.
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);
精彩评论