Piskous
Piskous

Reputation: 51

How to get version of android (4.1.1, 4.4.2,...) in Delphi

I would like to get the version of the Android device. In Java it is android.os.Build.VERSION.RELEASE, how is it in Delphi?

Upvotes: 4

Views: 2800

Answers (2)

Pax Beach
Pax Beach

Reputation: 2795

Use the code

if TOSVersion.Check(4, 2) then

It will be true if Android OS version is 4.2.2 (API 17) or higher.

Upvotes: 1

RRUZ
RRUZ

Reputation: 136391

You can use the System.SysUtils.TOSVersion record to get information about the operating system on which your application runs.

  TOSVersion = record
  public type
    TArchitecture = (arIntelX86, arIntelX64, arARM32);
    TPlatform = (pfWindows, pfMacOS, pfiOS, pfAndroid, pfWinRT, pfLinux);
  public const
    AllArchitectures = [arIntelX86, arIntelX64, arARM32];
    AllPlatforms = [pfWindows, pfMacOS, pfiOS, pfAndroid, pfWinRT, pfLinux];
  private
    class var FArchitecture: TArchitecture;
    class var FBuild: Integer;
    class var FMajor: Integer;
    class var FMinor: Integer;
    class var FName: string;
    class var FPlatform: TPlatform;
    class var FServicePackMajor: Integer;
    class var FServicePackMinor: Integer;
    class constructor Create;
  public
    class function Check(AMajor: Integer): Boolean; overload; static; inline;
    class function Check(AMajor, AMinor: Integer): Boolean; overload; static; inline;
    class function Check(AMajor, AMinor, AServicePackMajor: Integer): Boolean; overload; static; inline;
    class function ToString: string; static;
    class property Architecture: TArchitecture read FArchitecture;
    class property Build: Integer read FBuild;
    class property Major: Integer read FMajor;
    class property Minor: Integer read FMinor;
    class property Name: string read FName;
    class property Platform: TPlatform read FPlatform;
    class property ServicePackMajor: Integer read FServicePackMajor;
    class property ServicePackMinor: Integer read FServicePackMinor;
  end;

Upvotes: 7

Related Questions