如何在Delphi中获取android(4.1.1,4.4.2,...)的版本

时间:2014-04-03 13:25:43

标签: android delphi delphi-xe5 android-version

我想获得Android设备的版本。 在Java中它是android.os.Build.VERSION.RELEASE,它在Delphi中是怎么回事?

2 个答案:

答案 0 :(得分:3)

您可以使用System.SysUtils.TOSVersion记录获取有关运行应用程序的操作系统的信息。

  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;

答案 1 :(得分:0)

使用代码

if TOSVersion.Check(4, 2) then

如果Android OS版本是4.2.2(API 17)或更高版本,那将是真的。