Added in API level 1

PackageInfo


open class PackageInfo : Parcelable
kotlin.Any
   ↳ android.content.pm.PackageInfo

Overall information about the contents of a package. This corresponds to all of the information collected from AndroidManifest.xml.

Summary

Constants
static Int

Constant corresponding to auto in the android.R.attr#installLocation attribute.

static Int

Constant corresponding to internalOnly in the android.R.attr#installLocation attribute.

static Int

Constant corresponding to preferExternal in the android.R.attr#installLocation attribute.

static Int

Flag for requestedPermissionsFlags: the requested permission is currently granted to the application.

static Int

Flag for requestedPermissionsFlags: the requested permission was not explicitly requested via uses-permission, but was instead implicitly requested (e.g., for version compatibility reasons).

static Int

Flag for requestedPermissionsFlags: the requested permission has declared neverForLocation in their manifest as a strong assertion by a developer that they will never use this permission to derive the physical location of the device, regardless of android.Manifest.permission#ACCESS_FINE_LOCATION and/or android.Manifest.permission#ACCESS_COARSE_LOCATION being granted.

Inherited constants
Public constructors

Public methods
open Int

open String?

If the package is an APEX package (i.e. the value of

open Long

Returns the time at which the app was archived for the user.

open Long

Return versionCode and versionCodeMajor combined together as a single long value.

open Unit
setLongVersionCode(longVersionCode: Long)

Set the full version code in this PackageInfo, updating versionCode with the lower bits.

open String

open Unit
writeToParcel(dest: Parcel, parcelableFlags: Int)

Properties
static Parcelable.Creator<PackageInfo!>

Array<ActivityInfo!>?

Array of all <activity> tags included under <application>, or null if there were none.

ApplicationInfo?

Information collected from the <application> tag, or null if there was none.

Array<Attribution!>?

Array of all <attribution> tags included under <manifest>, or null if there were none.

Int

The revision number of the base APK for this package, as specified by the <manifest> tag's revisionCode attribute.

Array<ConfigurationInfo!>?

Application specified preferred configuration <uses-configuration> tags included under <manifest>, or null if there were none.

Array<FeatureGroupInfo!>?

Groups of features that this application has requested.

Long

The time at which the app was first installed.

IntArray?

All kernel group-IDs that have been assigned to this package.

Int

The install location requested by the package.

Array<InstrumentationInfo!>?

Array of all <instrumentation> tags included under <manifest>, or null if there were none.

Boolean

Whether the package is an APEX package.

Long

The time at which the app was last updated.

String

The name of this package.

Array<PermissionInfo!>?

Array of all <permission> tags included under <manifest>, or null if there were none.

Array<ProviderInfo!>?

Array of all <provider> tags included under <application>, or null if there were none.

Array<ActivityInfo!>?

Array of all <receiver> tags included under <application>, or null if there were none.

Array<FeatureInfo!>?

Features that this application has requested.

Array<String!>?

Array of all <uses-permission> tags included under <manifest>, or null if there were none.

IntArray?

Array of flags of all <uses-permission> tags included under <manifest>, or null if there were none.

Array<ServiceInfo!>?

Array of all <service> tags included under <application>, or null if there were none.

String?

The shared user ID name of this package, as specified by the <manifest> tag's sharedUserId attribute.

Int

The shared user ID label of this package, as specified by the <manifest> tag's sharedUserLabel attribute.

Array<Signature!>?

Array of all signatures read from the package file.

SigningInfo?

Signing information read from the package file, potentially including past signing certificates no longer used after signing certificate rotation.

Array<String!>

The names of any installed split APKs for this package.

IntArray

The revision number of any split APKs for this package, as specified by the <manifest> tag's revisionCode attribute.

Int

String?

The version name of this package, as specified by the <manifest> tag's versionName attribute, or null if there was none.

Constants

INSTALL_LOCATION_AUTO

Added in API level 21
static val INSTALL_LOCATION_AUTO: Int

Constant corresponding to auto in the android.R.attr#installLocation attribute.

Value: 0

INSTALL_LOCATION_INTERNAL_ONLY

Added in API level 21
static val INSTALL_LOCATION_INTERNAL_ONLY: Int

Constant corresponding to internalOnly in the android.R.attr#installLocation attribute.

Value: 1

INSTALL_LOCATION_PREFER_EXTERNAL

Added in API level 21
static val INSTALL_LOCATION_PREFER_EXTERNAL: Int

Constant corresponding to preferExternal in the android.R.attr#installLocation attribute.

Value: 2

REQUESTED_PERMISSION_GRANTED

Added in API level 16
static val REQUESTED_PERMISSION_GRANTED: Int

Flag for requestedPermissionsFlags: the requested permission is currently granted to the application.

Value: 2

REQUESTED_PERMISSION_IMPLICIT

Added in API level 34
static val REQUESTED_PERMISSION_IMPLICIT: Int

Flag for requestedPermissionsFlags: the requested permission was not explicitly requested via uses-permission, but was instead implicitly requested (e.g., for version compatibility reasons).

Value: 4

REQUESTED_PERMISSION_NEVER_FOR_LOCATION

Added in API level 31
static val REQUESTED_PERMISSION_NEVER_FOR_LOCATION: Int

Flag for requestedPermissionsFlags: the requested permission has declared neverForLocation in their manifest as a strong assertion by a developer that they will never use this permission to derive the physical location of the device, regardless of android.Manifest.permission#ACCESS_FINE_LOCATION and/or android.Manifest.permission#ACCESS_COARSE_LOCATION being granted.

Value: 65536

Public constructors

PackageInfo

Added in API level 1
PackageInfo()

Public methods

describeContents

Added in API level 1
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getApexPackageName

Added in API level 35
open fun getApexPackageName(): String?

If the package is an APEX package (i.e. the value of isApex is true), returns the package name of the APEX. If the package is one APK-in-APEX app, returns the package name of the parent APEX that contains the app. If the package is not one of the above two cases, returns null.

getArchiveTimeMillis

Added in API level 35
open fun getArchiveTimeMillis(): Long

Returns the time at which the app was archived for the user. Units are as per System#currentTimeMillis().
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

Return
Long Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

getLongVersionCode

Added in API level 28
open fun getLongVersionCode(): Long

Return versionCode and versionCodeMajor combined together as a single long value. The versionCodeMajor is placed in the upper 32 bits.

setLongVersionCode

Added in API level 28
open fun setLongVersionCode(longVersionCode: Long): Unit

Set the full version code in this PackageInfo, updating versionCode with the lower bits.

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 1
open fun writeToParcel(
    dest: Parcel,
    parcelableFlags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 1
static val CREATOR: Parcelable.Creator<PackageInfo!>

activities

Added in API level 1
var activities: Array<ActivityInfo!>?

Array of all <activity> tags included under <application>, or null if there were none. This is only filled in if the flag PackageManager#GET_ACTIVITIES was set.

applicationInfo

Added in API level 1
var applicationInfo: ApplicationInfo?

Information collected from the <application> tag, or null if there was none.

attributions

Added in API level 31
var attributions: Array<Attribution!>?

Array of all <attribution> tags included under <manifest>, or null if there were none. This is only filled if the flag PackageManager#GET_ATTRIBUTIONS_LONG was set.

baseRevisionCode

Added in API level 22
var baseRevisionCode: Int

The revision number of the base APK for this package, as specified by the <manifest> tag's revisionCode attribute.

configPreferences

Added in API level 3
var configPreferences: Array<ConfigurationInfo!>?

Application specified preferred configuration <uses-configuration> tags included under <manifest>, or null if there were none. This is only filled in if the flag PackageManager#GET_CONFIGURATIONS was set.

featureGroups

Added in API level 21
var featureGroups: Array<FeatureGroupInfo!>?

Groups of features that this application has requested. Each group contains a set of features that are required. A device must match the features listed in reqFeatures and one or more FeatureGroups in order to have satisfied the feature requirement.

firstInstallTime

Added in API level 9
var firstInstallTime: Long

The time at which the app was first installed. Units are as per System#currentTimeMillis().

gids

Added in API level 1
var gids: IntArray?

All kernel group-IDs that have been assigned to this package. This is only filled in if the flag PackageManager#GET_GIDS was set.

installLocation

Added in API level 21
var installLocation: Int

The install location requested by the package. From the android.R.attr#installLocation attribute, one of INSTALL_LOCATION_AUTO, INSTALL_LOCATION_INTERNAL_ONLY, INSTALL_LOCATION_PREFER_EXTERNAL

instrumentation

Added in API level 1
var instrumentation: Array<InstrumentationInfo!>?

Array of all <instrumentation> tags included under <manifest>, or null if there were none. This is only filled in if the flag PackageManager#GET_INSTRUMENTATION was set.

isApex

Added in API level 29
var isApex: Boolean

Whether the package is an APEX package.

lastUpdateTime

Added in API level 9
var lastUpdateTime: Long

The time at which the app was last updated. Units are as per System#currentTimeMillis().

packageName

Added in API level 1
var packageName: String

The name of this package. From the <manifest> tag's "name" attribute.

permissions

Added in API level 1
var permissions: Array<PermissionInfo!>?

Array of all <permission> tags included under <manifest>, or null if there were none. This is only filled in if the flag PackageManager#GET_PERMISSIONS was set.

providers

Added in API level 1
var providers: Array<ProviderInfo!>?

Array of all <provider> tags included under <application>, or null if there were none. This is only filled in if the flag PackageManager#GET_PROVIDERS was set.

receivers

Added in API level 1
var receivers: Array<ActivityInfo!>?

Array of all <receiver> tags included under <application>, or null if there were none. This is only filled in if the flag PackageManager#GET_RECEIVERS was set.

reqFeatures

Added in API level 5
var reqFeatures: Array<FeatureInfo!>?

Features that this application has requested.

requestedPermissions

Added in API level 1
var requestedPermissions: Array<String!>?

Array of all <uses-permission> tags included under <manifest>, or null if there were none. This is only filled in if the flag PackageManager#GET_PERMISSIONS was set. This list includes all permissions requested, even those that were not granted or known by the system at install time.

requestedPermissionsFlags

Added in API level 16
var requestedPermissionsFlags: IntArray?

Array of flags of all <uses-permission> tags included under <manifest>, or null if there were none. This is only filled in if the flag PackageManager#GET_PERMISSIONS was set. Each value matches the corresponding entry in requestedPermissions, and will have the flags REQUESTED_PERMISSION_GRANTED, REQUESTED_PERMISSION_IMPLICIT, and REQUESTED_PERMISSION_NEVER_FOR_LOCATION set as appropriate.

services

Added in API level 1
var services: Array<ServiceInfo!>?

Array of all <service> tags included under <application>, or null if there were none. This is only filled in if the flag PackageManager#GET_SERVICES was set.

sharedUserId

Added in API level 3
var sharedUserId: String?

The shared user ID name of this package, as specified by the <manifest> tag's sharedUserId attribute.

sharedUserLabel

Added in API level 3
var sharedUserLabel: Int

The shared user ID label of this package, as specified by the <manifest> tag's sharedUserLabel attribute.

signatures

Added in API level 1
Deprecated in API level 28
var signatures: Array<Signature!>?

Deprecated: use signingInfo instead

Array of all signatures read from the package file. This is only filled in if the flag PackageManager#GET_SIGNATURES was set. A package must be signed with at least one certificate which is at position zero. The package can be signed with additional certificates which appear as subsequent entries. Note: Signature ordering is not guaranteed to be stable which means that a package signed with certificates A and B is equivalent to being signed with certificates B and A. This means that in case multiple signatures are reported you cannot assume the one at the first position to be the same across updates. Deprecated This has been replaced by the PackageInfo#signingInfo field, which takes into account signing certificate rotation. For backwards compatibility in the event of signing certificate rotation, this will return the oldest reported signing certificate, so that an application will appear to callers as though no rotation occurred.

signingInfo

Added in API level 28
var signingInfo: SigningInfo?

Signing information read from the package file, potentially including past signing certificates no longer used after signing certificate rotation. This is only filled in if the flag PackageManager#GET_SIGNING_CERTIFICATES was set. Use this field instead of the deprecated signatures field. See SigningInfo for more information on its contents.

splitNames

Added in API level 21
var splitNames: Array<String!>

The names of any installed split APKs for this package.

splitRevisionCodes

Added in API level 22
var splitRevisionCodes: IntArray

The revision number of any split APKs for this package, as specified by the <manifest> tag's revisionCode attribute. Indexes are a 1:1 mapping against splitNames.

versionCode

Added in API level 1
Deprecated in API level 28
var versionCode: Int

Deprecated: Use getLongVersionCode() instead, which includes both this and the additional versionCodeMajor attribute. The version number of this package, as specified by the <manifest> tag's versionCode attribute.

versionName

Added in API level 1
var versionName: String?

The version name of this package, as specified by the <manifest> tag's versionName attribute, or null if there was none.