Jump to content
Nicolò Blunda

Get metadata string from Manifest

Recommended Posts

Hello.

To get string versionName value of field inside <manifest> key, in AndroidManifest.xml file, I use this code:

function GetFileVersionName: string;
var
  PackageManager: JPackageManager;
  PackageInfo   : JPackageInfo;
Begin
  PackageManager:= SharedActivity.getPackageManager;
  PackageInfo   := PackageManager.getPackageInfo(SharedActivityContext.getPackageName, TJPackageManager.JavaClass.GET_ACTIVITIES);
  Result        := JStringToString(PackageInfo.versionName);
End;

If the filed is in a meta-data key, inside <activity> section, like this...

 <meta-data android:name="productName" android:value="HelloWorld" />

how can change above code to retrive it?
Thanks.

Share this post


Link to post
0

Find the solution! After move <meta-data> key outside <activity> section, code to read value for name="productName" is:

function GetProductName: string;
var
  PackManager: JPackageManager;
  AppInfo    : JApplicationInfo;
Begin
  PackManager:= SharedActivity.getPackageManager;
  AppInfo    := PackManager.getApplicationInfo(SharedActivityContext.getPackageName, TJPackageManager.JavaClass.GET_META_DATA);
  Result     := JStringToString(AppInfo.metadata.getString(StringToJString('productName')));
End;

 

Edited by Nicolò Blunda

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×