开发者

Is it possible to use conditions at xml files? [duplicate]

This question already has answers here: Closed 11 years ago.

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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜