Package Info - StansAssets/com.stansassets.android-native GitHub Wiki

Android Native gives you access to the native Android PackageManager via AN_PackageManager class.

First of all, you need to get AN_PackageManager instance. See the example below:

using SA.Android.App;
using SA.Android.Content.Pm;
...

AN_PackageManager pm = AN_MainActivity.Instance.GetPackageManager();

Then you can retrieve information about any installed application, including your own. If you need to get the information about your own app, simply set a value of the packageName variable to your current application bundle name. See the example below:

using SA.Android.App;
using SA.Android.Content.Pm;
...

string packageName = "any.app.package.name";
var pm = AN_MainActivity.Instance.GetPackageManager();
AN_PackageInfo packageInfo =  pm.GetPackageInfo(packageName, 0);
Debug.Log("packageInfo.VersionName: " + packageInfo.VersionName);
Debug.Log("packageInfo.PackageName: " + packageInfo.PackageName);
Debug.Log("packageInfo.SharedUserId: " + packageInfo.SharedUserId);

You can learn more about how the Package manager may be used with the PackageManager Guide.

⚠️ **GitHub.com Fallback** ⚠️