Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One possible approach. In your AndroidManifest.xml add metadata to your Activities to keep the revision or whatever you want to use</p> <pre><code>&lt;activity android:name="SampleActivity"&gt; &lt;meta-data android:value="$Rev: 164 $" android:name="com.example.version" /&gt; &lt;/activity&gt; </code></pre> <p>then in your Activity</p> <pre><code>try { final ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); final String version = (String)ai.metaData.get("com.example.version"); System.out.println("version: " + version); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>You may also want to set <code>android:versionName="$Rev$"</code> in your manifest.</p> <p>To automate the process of incrementing the version number in <code>android:versionCode</code> and committing the <code>AndroidManifest.xml</code> there are various options, building with <code>maven</code> or <code>ant</code> could be alternatives but let's do it using Eclipse and ADT.</p> <p>First, add a builder to your project (<em>My Project -> Properties -> Builders</em>)</p> <p><img src="https://lh3.ggpht.com/_9_trc1obptk/S2NPRwIQzeI/AAAAAAAAAs8/ukmsfRnhZTY/s576/Screenshot-Properties%20for%20AndroidWasteBasket%20.png" alt="alt text"></p> <p>this builder should invoke the <code>android-increment-manifest-version</code> using the project's <code>AndroidManifest.xml</code> as the argument</p> <p><img src="https://lh4.ggpht.com/_9_trc1obptk/S2NPR_UB1aI/AAAAAAAAAs4/Jl5QkoQet6U/s640/Screenshot-Edit%20Configuration%20.png" alt="alt text"></p> <p>android-increment-manifest-version script is something like</p> <pre><code>#! /bin/bash # android-increment-manifest-version: # increment the version number found in the AndroidManifest.xml file # (android:versionCode="n") in place and commit it to subversion. # # Copyright (C) 2010 Diego Torres Milano - http://dtmilano.blogspot.com usage() { echo "usage: $PROGNAME AndroidManifest.xml" &gt;&amp;2 exit 1 } PROGNAME=$(basename $0) if [ "$#" -ne 1 ] then usage fi MANIFEST="$1" perl -npi -e 's/^(.*android:versionCode=")(\d+)(".*)$/"$1" . ($2+1) . "$3"/e;' $MANIFEST svn ci -m "Version incremented" $MANIFEST </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload