How to get the version of an Android application using the Delphi XE5? I need the "versionName" information.
Asked
Active
Viewed 3,690 times
1 Answers
6
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;

Shaun Roselt
- 1,650
- 5
- 18
- 44

RRUZ
- 134,889
- 20
- 356
- 483
-
Thanks, RRUZ. Perfect! Will be added to my library. – Carlos Santos Mar 15 '14 at 02:42