Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

delphi - Android Application Version (RAD Studio XE5)

How to get the version of an Android application using the Delphi XE5? I need the "versionName" information.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...