How to check the Android Os version Programmatically on the onCreate of very first screen of the App?
Asked
Active
Viewed 1,942 times
2
-
1possible duplicate of [Retrieving Android API version programmatically](http://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically) – Josh Lee Nov 12 '10 at 04:33
-
Possible duplicate of [Retrieving Android API version programmatically](https://stackoverflow.com/questions/3423754/retrieving-android-api-version-programmatically) – Cœur Jul 12 '17 at 16:32
2 Answers
5
Some hints to get you going bro :)
StringBuffer buf = new StringBuffer();
buf.append("VERSION.RELEASE {"+Build.VERSION.RELEASE+"}");
buf.append("\nVERSION.INCREMENTAL {"+Build.VERSION.INCREMENTAL+"}");
buf.append("\nVERSION.SDK {"+Build.VERSION.SDK+"}");
buf.append("\nBOARD {"+Build.BOARD+"}");
buf.append("\nBRAND {"+Build.BRAND+"}");
buf.append("\nDEVICE {"+Build.DEVICE+"}");
buf.append("\nFINGERPRINT {"+Build.FINGERPRINT+"}");
buf.append("\nHOST {"+Build.HOST+"}");
buf.append("\nID {"+Build.ID+"}");
Log.d("build",buf);

Muhammad Shahab
- 4,187
- 4
- 34
- 44
-
The value you should be most interested in is `Build.VERSION.SDK_INT` - `Build.VERSION.SDK` is the deprecated string form of the same data. – adamp Nov 12 '10 at 05:16
0
Build.VERSION.RELEASE;
That will give you the actual numbers of your version; aka 2.3.3 or 2.2. The problem with using Build.VERSION.SDK_INT is if you have a rooted phone or custom rom, you could have a none standard OS (aka my android is running 2.3.5) and that will return a null when using Build.VERSION.SDK_INT so Build.VERSION.RELEASE will work no matter what!
To use it, you could just do this;
String androidOS = Build.VERSION.RELEASE;

Falcon165o
- 2,875
- 1
- 20
- 31