How to get the version of an Android application using the Delphi XE5? I need the "versionName" information.
You can use the getPackageInfomethod 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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With