Android Application Version (RAD Studio XE5)

与世无争的帅哥 提交于 2019-11-27 07:05:43

问题


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


回答1:


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.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;


来源:https://stackoverflow.com/questions/22315571/android-application-version-rad-studio-xe5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!