0

I want to display the current revision number of my Android project to the user. I use the subclipse plugin for Eclipse and already found out that I somehow need the program svnversion.

I've found this answer, but I don't get at all where I have to change what and how I finally access the number to put it into a TextView. Also, I feel a bit sheepish about interfering with the Android build process.

Is there some easier explanation / example out there?

Kind regards, jellyfish

Community
  • 1
  • 1
jellyfish
  • 7,868
  • 11
  • 37
  • 49

2 Answers2

1

I would suggest not using the version control for showing version number. Revision numbers and app version are inherently different. You don't want to notch your app version for a spelling fix :-) .

What you can do is set your version name in the manifest to refer a string from values/string.xml . You can then show this string in the app where ever needed.

Ravi Vyas
  • 12,212
  • 6
  • 31
  • 47
  • Thanks that actually solves it, kind of. ;) I will give you the bounty as soon as I'm allowed to by the system. ^^ – jellyfish May 31 '11 at 07:49
0

You can get the name and numeric ID that are stored in your manifest with this:

public String getAppVerName() {
    String text;
    try {
        text = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        text = "Version Not Found";
    }
    return text;
}

Replace .versionName; with .versionId; to get the numeric value. I have a write up about this on my blog: http://www.aydabtudev.com/2011/03/android-tracking-version-usage.html

Bill Mote
  • 12,644
  • 7
  • 58
  • 82
  • is this really the build number? I keep getting "1.0", no matter how often I commit a new version... – jellyfish Apr 15 '11 at 12:05
  • It's the number that's stored in the manifest. That number must be incremented when you publish your app to the market. It does not coincide with the version number in your SVN repository. I misunderstood your question. – Bill Mote Apr 15 '11 at 12:23
  • Find a way to increment the manifest.xml on submit ... that would be useful ;) – Bill Mote Apr 15 '11 at 12:38
  • You could try to write an svn hook that increments the versionCode and versionName tags. – apesa Apr 19 '11 at 03:30