Android APIs
public class

PackageInfo

extends Object
implements Parcelable
java.lang.Object
   ↳ android.content.pm.PackageInfo

Class Overview

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

Summary

Constants
int INSTALL_LOCATION_AUTO Constant corresponding to auto in the installLocation attribute.
int INSTALL_LOCATION_INTERNAL_ONLY Constant corresponding to internalOnly in the installLocation attribute.
int INSTALL_LOCATION_PREFER_EXTERNAL Constant corresponding to preferExternal in the installLocation attribute.
int REQUESTED_PERMISSION_GRANTED Flag for requestedPermissionsFlags: the requested permission is currently granted to the application.
int REQUESTED_PERMISSION_REQUIRED Flag for requestedPermissionsFlags: the requested permission is required for the application to run; the user can not optionally disable it.
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<PackageInfo> CREATOR
public ActivityInfo[] activities Array of all <activity> tags included under <application>, or null if there were none.
public ApplicationInfo applicationInfo Information collected from the <application> tag, or null if there was none.
public int baseRevisionCode The revision number of the base APK for this package, as specified by the <manifest> tag's revisionCode attribute.
public ConfigurationInfo[] configPreferences Application specified preferred configuration <uses-configuration> tags included under <manifest>, or null if there were none.
public FeatureGroupInfo[] featureGroups Groups of features that this application has requested.
public long firstInstallTime The time at which the app was first installed.
public int[] gids All kernel group-IDs that have been assigned to this package.
public int installLocation The install location requested by the package.
public InstrumentationInfo[] instrumentation Array of all <instrumentation> tags included under <manifest>, or null if there were none.
public long lastUpdateTime The time at which the app was last updated.
public String packageName The name of this package.
public PermissionInfo[] permissions Array of all <permission> tags included under <manifest>, or null if there were none.
public ProviderInfo[] providers Array of all <provider> tags included under <application>, or null if there were none.
public ActivityInfo[] receivers Array of all <receiver> tags included under <application>, or null if there were none.
public FeatureInfo[] reqFeatures Features that this application has requested.
public String[] requestedPermissions Array of all <uses-permission> tags included under <manifest>, or null if there were none.
public int[] requestedPermissionsFlags Array of flags of all <uses-permission> tags included under <manifest>, or null if there were none.
public ServiceInfo[] services Array of all <service> tags included under <application>, or null if there were none.
public String sharedUserId The shared user ID name of this package, as specified by the <manifest> tag's sharedUserId attribute.
public int sharedUserLabel The shared user ID label of this package, as specified by the <manifest> tag's sharedUserLabel attribute.
public Signature[] signatures Array of all signatures read from the package file.
public String[] splitNames The names of any installed split APKs for this package.
public int[] splitRevisionCodes The revision number of any split APKs for this package, as specified by the <manifest> tag's revisionCode attribute.
public int versionCode The version number of this package, as specified by the <manifest> tag's versionCode attribute.
public String versionName The version name of this package, as specified by the <manifest> tag's versionName attribute.
Public Constructors
PackageInfo()
Public Methods
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel dest, int parcelableFlags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int INSTALL_LOCATION_AUTO

Added in API level 21

Constant corresponding to auto in the installLocation attribute.

Constant Value: 0 (0x00000000)

public static final int INSTALL_LOCATION_INTERNAL_ONLY

Added in API level 21

Constant corresponding to internalOnly in the installLocation attribute.

Constant Value: 1 (0x00000001)

public static final int INSTALL_LOCATION_PREFER_EXTERNAL

Added in API level 21

Constant corresponding to preferExternal in the installLocation attribute.

Constant Value: 2 (0x00000002)

public static final int REQUESTED_PERMISSION_GRANTED

Added in API level 16

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

Constant Value: 2 (0x00000002)

public static final int REQUESTED_PERMISSION_REQUIRED

Added in API level 16

Flag for requestedPermissionsFlags: the requested permission is required for the application to run; the user can not optionally disable it. Currently all permissions are required.

Constant Value: 1 (0x00000001)

Fields

public static final Creator<PackageInfo> CREATOR

Added in API level 1

public ActivityInfo[] activities

Added in API level 1

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

public ApplicationInfo applicationInfo

Added in API level 1

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

public int baseRevisionCode

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

public ConfigurationInfo[] configPreferences

Added in API level 3

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

public FeatureGroupInfo[] featureGroups

Added in API level 21

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.

See Also

public long firstInstallTime

Added in API level 9

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

public int[] gids

Added in API level 1

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

public int installLocation

Added in API level 21

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

public InstrumentationInfo[] instrumentation

Added in API level 1

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

public long lastUpdateTime

Added in API level 9

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

public String packageName

Added in API level 1

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

public PermissionInfo[] permissions

Added in API level 1

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

public ProviderInfo[] providers

Added in API level 1

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

public ActivityInfo[] receivers

Added in API level 1

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

public FeatureInfo[] reqFeatures

Added in API level 5

Features that this application has requested.

See Also

public String[] requestedPermissions

Added in API level 1

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

public int[] requestedPermissionsFlags

Added in API level 16

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 GET_PERMISSIONS was set. Each value matches the corresponding entry in requestedPermissions, and will have the flags REQUESTED_PERMISSION_REQUIRED and REQUESTED_PERMISSION_GRANTED set as appropriate.

public ServiceInfo[] services

Added in API level 1

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

public String sharedUserId

Added in API level 3

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

public int sharedUserLabel

Added in API level 3

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

public Signature[] signatures

Added in API level 1

Array of all signatures read from the package file. This is only filled in if the flag GET_SIGNATURES was set.

public String[] splitNames

Added in API level 21

The names of any installed split APKs for this package.

public int[] splitRevisionCodes

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.

public int versionCode

Added in API level 1

The version number of this package, as specified by the <manifest> tag's versionCode attribute.

public String versionName

Added in API level 1

The version name of this package, as specified by the <manifest> tag's versionName attribute.

Public Constructors

public PackageInfo ()

Added in API level 1

Public Methods

public int describeContents ()

Added in API level 1

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public String toString ()

Added in API level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel dest, int parcelableFlags)

Added in API level 1

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
parcelableFlags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.