问题描述
我喜欢包括在我的应用程序生成的一些变量。例如一个buildnumber。我可以通过从Ant构建脚本一些变量到我的Android应用程序,并使用该变量在Java中?
I like to include some build variables in my application. For example a buildnumber. Can I pass some variables from a ant build script to my Android application and use that variable in java?
任何人有一个链接或例子?
Anybody has a link or example?
推荐答案
只是填充版本号为一个字符串的XML文件,并把它读作正常。您可以使用替换任务做到这一点。
Just populate the build number into a string xml file and read it as normal. You can use the replace task to do that..
不要使用一个属性文件,因为没有Android原生的方式来阅读。本机方法是在XML文件中的字符串值。而且最好是将其更换成一个静态的字符串的XML文件,而不是Java源代码code了。
Dont use a properties file since there is not Android native way to read it. The native way are string values in the xml files. And it is better to replace it into a static strings xml file rather than java source code too.
这篇关于有没有办法通过蚂蚁变量的Java code(安卓)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!