You can use the getPackageInfo
method of the JPackageManager
class to get information about you package, from here access the versionName
property to get the versionName
.
Try this sample
uses
Androidapi.JNI.JavaTypes,
FMX.Helpers.Android,
Androidapi.Helpers,
Androidapi.JNI.GraphicsContentViewText;
{$R *.fmx}
procedure TForm25.Button1Click(Sender: TObject);
var
PackageManager: JPackageManager;
PackageInfo : JPackageInfo;
begin
PackageManager := SharedActivity.getPackageManager;
PackageInfo := PackageManager.getPackageInfo(SharedActivityContext.getPackageName(), TJPackageManager.JavaClass.GET_ACTIVITIES);
Edit1.Text:= JStringToString(PackageInfo.versionName);
end;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…