How to get the Android version (number) of your device without an extension

In most situations you only have to query whether you have an Android version lower than Android 11 or Android 10. In these cases you can also query it without an (API level) extension:

How to get the Android version (a non-string, but a number) of your device without showing any dots after it (e.g. 8 instead of 8.1 / Oreo or 4 instead of 4.4.x / KitKat):

Note: This will work until the Android version is less than 20.

iOS:

6 Likes

or ?

image

Draggable Block

7 Likes

Of course, the obvious is sometimes difficult to see. :wink:

5 Likes

I usually have these on, along with my white stick :sunglasses:

4 Likes

I checked the MIT sources. This was the source code for the PlatformVersion block.

  @SimpleProperty(description = "The dotted version number of the platform, such as 4.2.2 or 10.0. "
      + "This is platform specific and there is no guarantee that it has a particular format.")
  public String PlatformVersion() {
    return Build.VERSION.RELEASE;
  }

If you go to Android Developers, you see:

The user-visible version string. E.g., "1.0" or "3.4b5" or "bananas". This field is an opaque string. Do not assume that its value has any particular structure or that values of RELEASE from different releases can be somehow ordered.

2 Likes