Android Application Version (RAD Studio XE5)

前端 未结 1 1168
别跟我提以往
别跟我提以往 2020-12-11 07:06

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

相关标签:
1条回答
  • 2020-12-11 07:12

    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;
    
    0 讨论(0)
提交回复
热议问题