On Jan 19, 5:20 pm, Mark Murphy <[email protected]> wrote: > On Thu, Jan 19, 2012 at 11:14 AM, petter <[email protected]> wrote: > > How can I get a user-defined sysproperty in an Android app? > > There is no such concept in Android. > > > In a plain Java app I can do something like: > > > <target name="run" depends="git.revision"> > > <java classname="main" fork="true"> > > <sysproperty key="git.revision" value="${git.revision}"/> > > </java> > > </target> > > > And in main.java I do: > > > String gitSha1 = System.getProperty("git.revision"); > > > But how can I do this in an Android App? > > You don't, because you aren't in control of the VM. > > > I can get predefined system > > properties like "java.specification.vendor" etc. but I don't know how > > to attach my userdefined sysproperty to the dex generation. > > You don't, because "userdefined sysproperty" has nothing to do with > "dex generation" any more than it does "stock Java VM bytecode
True. I was thinking there was a hook already to generate userdefined properties, e.g. using a properties file or similar. > generation". As you note, in standard Java, you are defining system > properties via command-line arguments -- there are no command-line > arguments for SDK apps. > > > I can also get around this by generating a source file containting the > > properties, but I was hoping for a more suitable method. > > You could generate a resource file containing the properties (e.g., an > XML resource). > > Or, generate an asset file containing the properties. This is probably the simplest way. > Or, drop the properties entirely. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|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

