2
我想获取Android设备的版本。 在Java中,它是android.os.Build.VERSION.RELEASE,它在Delphi中怎么样?如何在Delphi中获取Android版本(4.1.1,4.4.2,...)
我想获取Android设备的版本。 在Java中,它是android.os.Build.VERSION.RELEASE,它在Delphi中怎么样?如何在Delphi中获取Android版本(4.1.1,4.4.2,...)
您可以使用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;
使用代码
if TOSVersion.Check(4, 2) then
这将是真实的,如果Android操作系统版本4.2.2是(API 17)或更高。
可能重复的问题... http://stackoverflow.com/questions/10547818/androidhow-to-find-the-android-version-name-programmatically – Bhaskar
不是真的,我需要它为Delphi XE5 – Piskous
请参阅Samples \ MobileCodeSnippets \ Delphi \ DeviceInfo项目,该项目不仅显示内部版本(例如,4.1.2),还显示通用名称(“Ice Cream Sandwich MR1”)和设备名称(“Samsung Galaxy S3”) 。 –