I'm using Delphi XE7 and I want to log some info about my app to a log file, so I need to port over the GetFileVersionInfo in MSWindows to work in Android. If possible I'd like a general routine that works for any file. I see that there is a Delphi example of how to get file version info in OSX here, but I cant find anything that points me to the relevant Android unit. Can anyone help please?
Asked
Active
Viewed 1,712 times
1
-
1What kind of version info would Android provide for the files my app creates? – greenapps Sep 25 '14 at 15:37
-
@greenapps: Take a look at your project options 'Version Info'. For Windows, that stuffs version info into the project exe. For Android, it is similar. I don't know where the version info goes, but hey - who cares! – Brian Frost Sep 25 '14 at 20:20
1 Answers
7
Here's a quick example:
uses
...
Androidapi.Helpers,
Androidapi.JNI.App,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.NativeActivity;
function GetPackageInfo: JPackageInfo;
var
Activity: JActivity;
begin
Activity := TJNativeActivity.Wrap(PANativeActivity(System.DelphiActivity)^.clazz);
Result := Activity.getPackageManager.getPackageInfo(Activity.getPackageName, 0);
end;
procedure TPForm.FormCreate(Sender: TObject);
var
Info: JPackageInfo;
begin
Info := GetPackageInfo;
Label1.Text := Format('versionName: "%s", versionCode: %d', [JStringToString(Info.versionName), Info.versionCode]);
end;

Ondrej Kelle
- 36,941
- 2
- 65
- 128
-
You're the man! Perfect thanks. So perfect in fact that I don't suppose you have sample code for accessing Hardware.USB...?! – Brian Frost Sep 25 '14 at 20:21