views:

69

answers:

1

I know how to get the API level, android.os.Build.VERSION.SDK_INT, but there are also several revisions of each level release, e.g. for 2.1 there's rev 1 and 2. How do I determine the revision of a build?

The reason i'd like to know this is that I have a workaround for a bug in Android 2.1 (and 2.2), and this workaround will break the moment the corresponding bug is fixed. So right now i'm in the odd position of hoping that the bug won't be fixed (at least not until I can find an answer to above question).

+1  A: 

I'm not sure which revision you're reffering to, but the revision you set in your manifest file you can get with the following code:

paramContext is your Context object

    PackageManager localPackageManager = paramContext.getPackageManager();
    PackageInfo localPackageInfo = localPackageManager.getPackageInfo(paramContext.getPackageName(), 0);
    String version = localPackageInfo.versionName;

If you want to extract the build version, use this code:

String version = Build.VERSION.RELEASE;
Roflcoptr
I guess you only read the title, and not the actual question? I am referring to Android versions and revision. The first part of your answer does me no good. The RELEASE string you point to contains the name of the release, and is basically undocumented. So thanks for replying, but my question remains unanswered.
hermo
Have you ever tested my answer before complaing about it? It's not my problem that it is not well documented.I installed only for you revision1 of android 2.1 and then Build.VERSION.RELEASE returns 2.1. Then i installed revision2 of android2.1 and then Build.VERSION.RELEASE returned: 2.1-update1
Roflcoptr
edit/add: So it should be clearly possible to distinguish different revisions of the same version.
Roflcoptr
Sorry if I sounded a bit grumpy, didn't mean to complain about your answer but the first part of it had nothing to do with the question. I agree it should be possible to do it, but the question is still: how to do it.
hermo
The RELEASE string being undocumented (which I never said was your fault BTW:) means I don't know what value it will have in coming revisions, I can only guess. And to know what values it has in existing revisions I have to check all of them. As a software developer I wouldn't call this an acceptable solution, so I will hold out a bit longer hoping there is a better answer, or that someone can convince me that there is no other solution. Cheers.
hermo
yes ok. then i'll hope someone will find a better solution. I thought you were only concerned about 2.1 and 2.2.
Roflcoptr