Skip to main content

ApplicationInfo

ApplicationInfo is a class that contains information about a particular Android application. The information is collected from the application's AndroidManifest.xml's <application> tag.

Basic Usages​

Getting ApplicationInfo​

The first thing you might want to do is retrieve the ApplicationInfo instance.

Getting Own ApplicationInfo​

You can retrieve your app's ApplicationInfo instance by using getApplicationInfo() method and pass your own package name as parameter:

import android.content.Context
import android.util.Log

try {
val applicationInfo = context.packageManager.getApplicationInfo(
context.packageName,
0,
)
} catch (e: Exception) {
Log.e("TAG", e.message, e)
}

Getting Other Application's ApplicationInfo​

You can retrieve other app's ApplicationInfo instance by using the same method, but you need to add the package name into your AndroidManifest.xml's <queries> tag:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application>
</application>

<queries>
<package android:name="com.hanmajid.myotherapp" />
</queries>

</manifest>

Then, you can retrieve the app's ApplicationInfo like this:

import android.content.Context
import android.util.Log

try {
val applicationInfo = context.packageManager.getApplicationInfo(
"com.hanmajid.myotherapp",
0,
)
} catch (e: Exception) {
Log.e("TAG", e.message, e)
}

Properties​

Application Category​

Application category is a value that can be set in the application's AndroidManifest.xml's attribute. We can retrieve this value in ApplicationInfo by using category property.

val appCategory = applicationInfo.category

Storage UUID​

We can retrieve the UUID of the storage volume on which the application is being hosted by using storageUuid property.

val storageUuid = applicationInfo.storageUuid

References​