PackageInfo
  public
  
  
  
  class
  PackageInfo
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | 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 | |
|---|---|
| int | INSTALL_LOCATION_AUTOConstant corresponding to  | 
| int | INSTALL_LOCATION_INTERNAL_ONLYConstant corresponding to  | 
| int | INSTALL_LOCATION_PREFER_EXTERNALConstant corresponding to  | 
| int | REQUESTED_PERMISSION_GRANTEDFlag for  | 
| int | REQUESTED_PERMISSION_IMPLICITFlag for  | 
| int | REQUESTED_PERMISSION_NEVER_FOR_LOCATIONFlag for  | 
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<PackageInfo> | CREATOR
 | 
| 
    public
    
    
    ActivityInfo[] | activitiesArray of all  | 
| 
    public
    
    
    ApplicationInfo | applicationInfoInformation collected from the <application> tag, or null if there was none. | 
| 
    public
    
    
    Attribution[] | attributionsArray of all  | 
| 
    public
    
    
    int | baseRevisionCodeThe revision number of the base APK for this package, as specified by the
 <manifest> tag's
  | 
| 
    public
    
    
    ConfigurationInfo[] | configPreferencesApplication specified preferred configuration
  | 
| 
    public
    
    
    FeatureGroupInfo[] | featureGroupsGroups of features that this application has requested. | 
| 
    public
    
    
    long | firstInstallTimeThe time at which the app was first installed. | 
| 
    public
    
    
    int[] | gidsAll kernel group-IDs that have been assigned to this package. | 
| 
    public
    
    
    int | installLocationThe install location requested by the package. | 
| 
    public
    
    
    InstrumentationInfo[] | instrumentationArray of all  | 
| 
    public
    
    
    boolean | isApexWhether the package is an APEX package. | 
| 
    public
    
    
    long | lastUpdateTimeThe time at which the app was last updated. | 
| 
    public
    
    
    String | packageNameThe name of this package. | 
| 
    public
    
    
    PermissionInfo[] | permissionsArray of all  | 
| 
    public
    
    
    ProviderInfo[] | providersArray of all  | 
| 
    public
    
    
    ActivityInfo[] | receiversArray of all  | 
| 
    public
    
    
    FeatureInfo[] | reqFeaturesFeatures that this application has requested. | 
| 
    public
    
    
    String[] | requestedPermissionsArray of all  | 
| 
    public
    
    
    int[] | requestedPermissionsFlagsArray of flags of all  | 
| 
    public
    
    
    ServiceInfo[] | servicesArray of all  | 
| 
    public
    
    
    String | sharedUserIdThe shared user ID name of this package, as specified by the <manifest>
 tag's  | 
| 
    public
    
    
    int | sharedUserLabelThe shared user ID label of this package, as specified by the <manifest>
 tag's  | 
| 
    public
    
    
    Signature[] | signatures
      This field was deprecated
      in API level 28.
    use  | 
| 
    public
    
    
    SigningInfo | signingInfoSigning information read from the package file, potentially including past signing certificates no longer used after signing certificate rotation. | 
| 
    public
    
    
    String[] | splitNamesThe names of any installed split APKs for this package. | 
| 
    public
    
    
    int[] | splitRevisionCodesThe revision number of any split APKs for this package, as specified by
 the <manifest> tag's
  | 
| 
    public
    
    
    int | versionCode
      This field was deprecated
      in API level 28.
    Use  | 
| 
    public
    
    
    String | versionNameThe version name of this package, as specified by the <manifest>
 tag's  | 
| Public constructors | |
|---|---|
| 
      PackageInfo()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        int | 
      describeContents()
      Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | 
| 
        
        
        
        
        
        String | 
      getApexPackageName()
      If the package is an APEX package (i.e. | 
| 
        
        
        
        
        
        long | 
      getArchiveTimeMillis()
      Returns the time at which the app was archived for the user. | 
| 
        
        
        
        
        
        long | 
      getLongVersionCode()
      Return  | 
| 
        
        
        
        
        
        boolean | 
      isAppMetadataVerified()
      Returns the verification status of the App Metadata of the package. | 
| 
        
        
        
        
        
        void | 
      setLongVersionCode(long longVersionCode)
      Set the full version code in this PackageInfo, updating  | 
| 
        
        
        
        
        
        String | 
      toString()
      Returns a string representation of the object. | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel dest, int parcelableFlags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
Constants
INSTALL_LOCATION_AUTO
public static final int INSTALL_LOCATION_AUTO
Constant corresponding to auto in the
 R.attr.installLocation attribute.
Constant Value: 0 (0x00000000)
INSTALL_LOCATION_INTERNAL_ONLY
public static final int INSTALL_LOCATION_INTERNAL_ONLY
Constant corresponding to internalOnly in the
 R.attr.installLocation attribute.
Constant Value: 1 (0x00000001)
INSTALL_LOCATION_PREFER_EXTERNAL
public static final int INSTALL_LOCATION_PREFER_EXTERNAL
Constant corresponding to preferExternal in the
 R.attr.installLocation attribute.
Constant Value: 2 (0x00000002)
REQUESTED_PERMISSION_GRANTED
public static final int REQUESTED_PERMISSION_GRANTED
Flag for requestedPermissionsFlags: the requested permission
 is currently granted to the application.
Constant Value: 2 (0x00000002)
REQUESTED_PERMISSION_IMPLICIT
public static final int REQUESTED_PERMISSION_IMPLICIT
Flag for requestedPermissionsFlags: the requested permission was
 not explicitly requested via uses-permission, but was instead implicitly
 requested (e.g., for version compatibility reasons).
Constant Value: 4 (0x00000004)
REQUESTED_PERMISSION_NEVER_FOR_LOCATION
public static final int REQUESTED_PERMISSION_NEVER_FOR_LOCATION
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
 Manifest.permission.ACCESS_FINE_LOCATION and/or
 Manifest.permission.ACCESS_COARSE_LOCATION being granted.
Constant Value: 65536 (0x00010000)
Fields
activities
public ActivityInfo[] activities
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
public ApplicationInfo applicationInfo
Information collected from the <application> tag, or null if there was none.
attributions
public Attribution[] attributions
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
public int baseRevisionCode
The revision number of the base APK for this package, as specified by the
 <manifest> tag's
 revisionCode
 attribute.
configPreferences
public ConfigurationInfo[] configPreferences
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
public FeatureGroupInfo[] featureGroups
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:
firstInstallTime
public long firstInstallTime
The time at which the app was first installed.  Units are as
 per System.currentTimeMillis().
gids
public int[] gids
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
public int installLocation
The install location requested by the package. From the
 R.attr.installLocation attribute, one of
 INSTALL_LOCATION_AUTO, INSTALL_LOCATION_INTERNAL_ONLY,
 INSTALL_LOCATION_PREFER_EXTERNAL
instrumentation
public InstrumentationInfo[] instrumentation
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.
lastUpdateTime
public long lastUpdateTime
The time at which the app was last updated.  Units are as
 per System.currentTimeMillis().
packageName
public String packageName
The name of this package. From the <manifest> tag's "name" attribute.
permissions
public PermissionInfo[] permissions
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
public ProviderInfo[] providers
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
public ActivityInfo[] receivers
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
public FeatureInfo[] reqFeatures
Features that this application has requested.
See also:
requestedPermissions
public String[] requestedPermissions
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
public int[] requestedPermissionsFlags
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
public ServiceInfo[] services
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
public String sharedUserId
The shared user ID name of this package, as specified by the <manifest>
 tag's sharedUserId
 attribute.
sharedUserLabel
public int sharedUserLabel
The shared user ID label of this package, as specified by the <manifest>
 tag's sharedUserLabel
 attribute.
signatures
public Signature[] signatures
      This field was deprecated
      in API level 28.
    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
public 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
public String[] splitNames
The names of any installed split APKs for this package.
splitRevisionCodes
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.
versionCode
public int versionCode
      This field was deprecated
      in API level 28.
    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.
  
See also:
versionName
public String versionName
The version name of this package, as specified by the <manifest>
 tag's versionName
 attribute, or null if there was none.
Public constructors
Public methods
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
 instance's marshaled representation. For example, if the object will
 include a file descriptor in the output of writeToParcel(android.os.Parcel, int),
 the return value of this method must include the
 CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
| int | a bitmask indicating the set of special object types marshaled
 by this Parcelable object instance.
 Value is either 0orCONTENTS_FILE_DESCRIPTOR | 
getApexPackageName
public String getApexPackageName ()
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.
| Returns | |
|---|---|
| String | |
getArchiveTimeMillis
public long getArchiveTimeMillis ()
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.
| Returns | |
|---|---|
| long | Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. | 
getLongVersionCode
public long getLongVersionCode ()
Return versionCode and
 versionCodeMajor combined
 together as a single long value.  The
 versionCodeMajor is placed in
 the upper 32 bits.
| Returns | |
|---|---|
| long | |
isAppMetadataVerified
public boolean isAppMetadataVerified ()
Returns the verification status of the App Metadata of the package. This status is set at the package installation time by the developer verification service provider.
| Returns | |
|---|---|
| boolean | |
setLongVersionCode
public void setLongVersionCode (long longVersionCode)
Set the full version code in this PackageInfo, updating versionCode
 with the lower bits.
| Parameters | |
|---|---|
| longVersionCode | long | 
See also:
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
| String | a string representation of the object. | 
writeToParcel
public void writeToParcel (Parcel dest, int parcelableFlags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| dest | Parcel: The Parcel in which the object should be written.
 This value cannot benull. | 
| parcelableFlags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
