开发者

using svnversion (subclipse) with android - get revision number

开发者 https://www.devze.com 2023-02-26 12:48 出处:网络
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 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 开发者_Python百科easier explanation / example out there?

Kind regards, jellyfish


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.


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

0

精彩评论

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

关注公众号