PackageInstaller
  public
  
  
  
  class
  PackageInstaller
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.content.pm.PackageInstaller | 
Offers the ability to install, upgrade, and remove applications on the device. This includes support for apps packaged either as a single "monolithic" APK, or apps packaged as multiple "split" APKs.
 An app is delivered for installation through a
 PackageInstaller.Session, which any app can create. Once the session
 is created, the installer can stream one or more APKs into place until it
 decides to either commit or destroy the session. Committing may require user
 intervention to complete the installation, unless the caller falls into one of the
 following categories, in which case the installation will complete automatically.
 
- the device owner
- the affiliated profile owner
Sessions can install brand new apps, upgrade existing apps, or add new splits into an existing app.
 Apps packaged as multiple split APKs always consist of a single "base" APK
 (with a null split name) and zero or more "split" APKs (with unique
 split names). Any subset of these APKs can be installed together, as long as
 the following constraints are met:
 
- All APKs must have the exact same package name, version code, and signing certificates.
- All APKs must have unique split names.
- All installations must contain a single base APK.
 The ApiDemos project contains examples of using this API:
 ApiDemos/src/com/example/android/apis/content/InstallApk*.java.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | PackageInstaller.InstallConstraintsA class to encapsulate constraints for installation. | 
| 
        
        
        
        
        class | PackageInstaller.InstallConstraintsResultThe callback result of  | 
| 
        
        
        
        
        class | PackageInstaller.PreapprovalDetailsDetails for requesting the pre-commit install approval. | 
| 
        
        
        
        
        class | PackageInstaller.SessionAn installation that is being actively staged. | 
| 
        
        
        
        
        class | PackageInstaller.SessionCallbackEvents for observing session lifecycle. | 
| 
        
        
        
        
        class | PackageInstaller.SessionInfoDetails for an active install session. | 
| 
        
        
        
        
        class | PackageInstaller.SessionParamsParameters for creating a new  | 
| 
        
        
        
        
        class | PackageInstaller.UnarchivalStateUsed to communicate the unarchival state in  | 
| Constants | |
|---|---|
| String | ACTION_SESSION_COMMITTEDBroadcast Action: Explicit broadcast sent to the last known default launcher when a session for a new install is committed. | 
| String | ACTION_SESSION_DETAILSActivity Action: Show details about a particular install session. | 
| String | ACTION_SESSION_UPDATEDBroadcast Action: Send information about a staged install session when its state is updated. | 
| int | DEVELOPER_VERIFICATION_FAILED_REASON_DEVELOPER_BLOCKEDDeveloper verification failed because the developer cannot be verified, as reported by the
 verifier via
  | 
| int | DEVELOPER_VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLEDeveloper verification failed because the network is unavailable. | 
| int | DEVELOPER_VERIFICATION_FAILED_REASON_UNKNOWNDeveloper verification failed because of unknown reasons, such as when the verifier times out or cannot be connected. | 
| String | EXTRA_DEVELOPER_VERIFICATION_EXTENSION_RESPONSEAn extra containing the response provided by the developer verifier to any extension params provided by the installer. | 
| String | EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASONWhen an installation fails because the developer verification was incomplete or blocked,
 this extra provides a code that explains the reason, such
 as  | 
| String | EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMEDAn extra containing a boolean indicating whether the lite version of the developer verification was performed on the app to be installed. | 
| String | EXTRA_INSTALL_CONSTRAINTSThe  | 
| String | EXTRA_INSTALL_CONSTRAINTS_RESULTThe  | 
| String | EXTRA_OTHER_PACKAGE_NAMEAnother package name relevant to a status. | 
| String | EXTRA_PACKAGE_NAMEPackage name that an operation is working with. | 
| String | EXTRA_PRE_APPROVALIndicate if the status is for a pre-approval request. | 
| String | EXTRA_SESSION
 | 
| String | EXTRA_SESSION_IDAn integer session ID that an operation is working with. | 
| String | EXTRA_STATUSCurrent status of an operation. | 
| String | EXTRA_STATUS_MESSAGEDetailed string representation of the status, including raw details that are useful for debugging. | 
| String | EXTRA_STORAGE_PATHStorage path relevant to a status. | 
| String | EXTRA_UNARCHIVE_ALL_USERSIf true, the requestor of the unarchival has specified that the app should be unarchived for all users. | 
| String | EXTRA_UNARCHIVE_IDExtra field for the unarchive ID. | 
| String | EXTRA_UNARCHIVE_PACKAGE_NAMEExtra field for the package name of a package that is requested to be unarchived. | 
| String | EXTRA_UNARCHIVE_STATUSCurrent status of an unarchive operation. | 
| int | PACKAGE_SOURCE_DOWNLOADED_FILECode indicating that the package being installed comes from a file that was downloaded to the device by the user. | 
| int | PACKAGE_SOURCE_LOCAL_FILECode indicating that the package being installed comes from a local file on the device. | 
| int | PACKAGE_SOURCE_OTHERCode indicating that the package being installed is from a source not reflected by any other package source constant. | 
| int | PACKAGE_SOURCE_STORECode indicating that the package being installed is from a store. | 
| int | PACKAGE_SOURCE_UNSPECIFIEDThe installer did not call  | 
| int | STATUS_FAILUREThe operation failed in a generic way. | 
| int | STATUS_FAILURE_ABORTEDThe operation failed because it was actively aborted. | 
| int | STATUS_FAILURE_BLOCKEDThe operation failed because it was blocked. | 
| int | STATUS_FAILURE_CONFLICTThe operation failed because it conflicts (or is inconsistent with) with another package already installed on the device. | 
| int | STATUS_FAILURE_INCOMPATIBLEThe operation failed because it is fundamentally incompatible with this device. | 
| int | STATUS_FAILURE_INVALIDThe operation failed because one or more of the APKs was invalid. | 
| int | STATUS_FAILURE_STORAGEThe operation failed because of storage issues. | 
| int | STATUS_FAILURE_TIMEOUTThe operation failed because it didn't complete within the specified timeout. | 
| int | STATUS_PENDING_USER_ACTIONUser action is currently required to proceed. | 
| int | STATUS_SUCCESSThe operation succeeded. | 
| int | UNARCHIVAL_ERROR_INSTALLER_DISABLEDThe installer responsible for the unarchival is disabled. | 
| int | UNARCHIVAL_ERROR_INSTALLER_UNINSTALLEDThe installer responsible for the unarchival has been uninstalled The system will return this status if appropriate. | 
| int | UNARCHIVAL_ERROR_INSUFFICIENT_STORAGENot enough storage to unarchive the application. | 
| int | UNARCHIVAL_ERROR_NO_CONNECTIVITYThe device is not connected to the internet | 
| int | UNARCHIVAL_ERROR_USER_ACTION_NEEDEDThe user needs to interact with the installer to enable the installation. | 
| int | UNARCHIVAL_GENERIC_ERRORGeneric error: The app cannot be unarchived. | 
| int | UNARCHIVAL_OKThe unarchival is possible and will commence. | 
| Public methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      abandonSession(int sessionId)
      Completely abandon the given session, destroying all staged data and rendering it invalid. | 
| 
        
        
        
        
        
        void | 
      checkInstallConstraints(List<String> packageNames, PackageInstaller.InstallConstraints constraints, Executor executor, Consumer<PackageInstaller.InstallConstraintsResult> callback)
      Check if install constraints are satisfied for the given packages. | 
| 
        
        
        
        
        
        void | 
      commitSessionAfterInstallConstraintsAreMet(int sessionId, IntentSender statusReceiver, PackageInstaller.InstallConstraints constraints, long timeoutMillis)
      Commit the session when all constraints are satisfied. | 
| 
        
        
        
        
        
        int | 
      createSession(PackageInstaller.SessionParams params)
      Create a new session using the given parameters, returning a unique ID that represents the session. | 
| 
        
        
        
        
        
        PackageInstaller.SessionInfo | 
      getActiveStagedSession()
      
      This method was deprecated
      in API level 30.
    Use  | 
| 
        
        
        
        
        
        List<PackageInstaller.SessionInfo> | 
      getActiveStagedSessions()
      Returns list of active staged sessions. | 
| 
        
        
        
        
        
        List<PackageInstaller.SessionInfo> | 
      getAllSessions()
      Return list of all known install sessions, regardless of the installer. | 
| 
        
        
        
        final
        
        ComponentName | 
      getDeveloperVerificationServiceProvider()
      Return the component name of the developer verification service provider, for the purpose of interacting with the specific verifier in relation to extension parameters and response structure. | 
| 
        
        
        
        
        
        List<PackageInstaller.SessionInfo> | 
      getMySessions()
      Return list of all known install sessions owned by the calling app. | 
| 
        
        
        
        
        
        PackageInstaller.SessionInfo | 
      getSessionInfo(int sessionId)
      Return details for a specific session. | 
| 
        
        
        
        
        
        List<PackageInstaller.SessionInfo> | 
      getStagedSessions()
      Return list of all staged install sessions. | 
| 
        
        
        
        
        
        void | 
      installExistingPackage(String packageName, int installReason, IntentSender statusReceiver)
      Install the given package, which already exists on the device, for the user for which this installer was created. | 
| 
        
        
        
        
        
        void | 
      installPackageArchived(ArchivedPackageInfo archivedPackageInfo, PackageInstaller.SessionParams sessionParams, IntentSender statusReceiver)
      Install package in an archived state. | 
| 
        
        
        
        
        
        PackageInstaller.Session | 
      openSession(int sessionId)
      Open an existing session to actively perform work. | 
| 
        
        
        
        
        
        void | 
      registerSessionCallback(PackageInstaller.SessionCallback callback, Handler handler)
      Register to watch for session lifecycle events. | 
| 
        
        
        
        
        
        void | 
      registerSessionCallback(PackageInstaller.SessionCallback callback)
      Register to watch for session lifecycle events. | 
| 
        
        
        
        
        
        void | 
      reportUnarchivalState(PackageInstaller.UnarchivalState unarchivalState)
      Reports the state of an unarchival to the system. | 
| 
        
        
        
        
        
        void | 
      reportUnarchivalStatus(int unarchiveId, int status, long requiredStorageBytes, PendingIntent userActionIntent)
      Reports the status of an unarchival to the system. | 
| 
        
        
        
        
        
        void | 
      requestArchive(String packageName, IntentSender statusReceiver)
      Requests to archive a package which is currently installed. | 
| 
        
        
        
        
        
        void | 
      requestUnarchive(String packageName, IntentSender statusReceiver)
      Requests to unarchive a currently archived package. | 
| 
        
        
        
        
        
        void | 
      uninstall(String packageName, IntentSender statusReceiver)
      Uninstall the given package, removing it completely from the device. | 
| 
        
        
        
        
        
        void | 
      uninstall(VersionedPackage versionedPackage, int flags, IntentSender statusReceiver)
      Uninstall the given package with a specific version code, removing it completely from the device. | 
| 
        
        
        
        
        
        void | 
      uninstall(VersionedPackage versionedPackage, IntentSender statusReceiver)
      Uninstall the given package with a specific version code, removing it completely from the device. | 
| 
        
        
        
        
        
        void | 
      uninstallExistingPackage(String packageName, IntentSender statusReceiver)
      Uninstall the given package for the user for which this installer was created if the package will still exist for other users on the device. | 
| 
        
        
        
        
        
        void | 
      unregisterSessionCallback(PackageInstaller.SessionCallback callback)
      Unregister a previously registered callback. | 
| 
        
        
        
        
        
        void | 
      updateSessionAppIcon(int sessionId, Bitmap appIcon)
      Update the icon representing the app being installed in a specific session. | 
| 
        
        
        
        
        
        void | 
      updateSessionAppLabel(int sessionId, CharSequence appLabel)
      Update the label representing the app being installed in a specific session. | 
| 
        
        
        
        
        
        void | 
      waitForInstallConstraints(List<String> packageNames, PackageInstaller.InstallConstraints constraints, IntentSender callback, long timeoutMillis)
      Similar to  | 
| Inherited methods | |
|---|---|
Constants
ACTION_SESSION_COMMITTED
public static final String ACTION_SESSION_COMMITTED
Broadcast Action: Explicit broadcast sent to the last known default launcher when a session
 for a new install is committed. For managed profile, this is sent to the default launcher
 of the primary profile.
 For user-profiles that have items restricted on home screen, this broadcast is sent to
 the default launcher of the primary profile, only if it has either
 ERROR(/Manifest.permission.ACCESS_HIDDEN_PROFILES_FULL) or
 ERROR(/Manifest.permission.ACCESS_HIDDEN_PROFILES) permission.
 
 The associated session is defined in EXTRA_SESSION and the user for which this
 session was created in Intent.EXTRA_USER.
Constant Value: "android.content.pm.action.SESSION_COMMITTED"
ACTION_SESSION_DETAILS
public static final String ACTION_SESSION_DETAILS
Activity Action: Show details about a particular install session. This may surface actions such as pause, resume, or cancel.
 This should always be scoped to the installer package that owns the
 session. Clients should use SessionInfo.createDetailsIntent() to
 build this intent correctly.
 
In some cases, a matching Activity may not exist, so ensure you safeguard against this.
 The session to show details for is defined in EXTRA_SESSION_ID.
Constant Value: "android.content.pm.action.SESSION_DETAILS"
ACTION_SESSION_UPDATED
public static final String ACTION_SESSION_UPDATED
Broadcast Action: Send information about a staged install session when its state is updated.
 The associated session information is defined in EXTRA_SESSION.
Constant Value: "android.content.pm.action.SESSION_UPDATED"
DEVELOPER_VERIFICATION_FAILED_REASON_DEVELOPER_BLOCKED
public static final int DEVELOPER_VERIFICATION_FAILED_REASON_DEVELOPER_BLOCKED
Developer verification failed because the developer cannot be verified, as reported by the
 verifier via
 ERROR(DeveloperVerificationSession.reportVerificationComplete(DeveloperVerificationStatus)/android.content.pm.verify.developer.DeveloperVerificationSession#reportVerificationComplete(android.content.pm.verify.developer.DeveloperVerificationStatus) DeveloperVerificationSession.reportVerificationComplete(DeveloperVerificationStatus))
 or
 ERROR(DeveloperVerificationSession.reportVerificationComplete(
 DeveloperVerificationStatus, PersistableBundle)/android.content.pm.verify.developer.DeveloperVerificationSession#reportVerificationComplete(android.content.pm.verify.developer.DeveloperVerificationStatus,android.os.PersistableBundle) DeveloperVerificationSession.reportVerificationComplete(
 DeveloperVerificationStatus, PersistableBundle))
Constant Value: 2 (0x00000002)
DEVELOPER_VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE
public static final int DEVELOPER_VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE
Developer verification failed because the network is unavailable. This corresponds to the
 status of
 ERROR(DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE/android.content.pm.verify.developer.DeveloperVerificationSession#DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE)
 reported by the verifier via
 ERROR(DeveloperVerificationSession.reportVerificationIncomplete(int)/android.content.pm.verify.developer.DeveloperVerificationSession#reportVerificationIncomplete(int) DeveloperVerificationSession.reportVerificationIncomplete(int)).
Constant Value: 1 (0x00000001)
DEVELOPER_VERIFICATION_FAILED_REASON_UNKNOWN
public static final int DEVELOPER_VERIFICATION_FAILED_REASON_UNKNOWN
Developer verification failed because of unknown reasons, such as when the verifier times out
 or cannot be connected. It can also corresponds to the status of
 ERROR(DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_UNKNOWN/android.content.pm.verify.developer.DeveloperVerificationSession#DEVELOPER_VERIFICATION_INCOMPLETE_UNKNOWN DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_UNKNOWN) reported by
 the verifier via ERROR(DeveloperVerificationSession.reportVerificationIncomplete(int)/android.content.pm.verify.developer.DeveloperVerificationSession#reportVerificationIncomplete(int) DeveloperVerificationSession.reportVerificationIncomplete(int)).
Constant Value: 0 (0x00000000)
EXTRA_DEVELOPER_VERIFICATION_EXTENSION_RESPONSE
public static final String EXTRA_DEVELOPER_VERIFICATION_EXTENSION_RESPONSE
An extra containing the response provided by the developer verifier to any extension
 params provided by the installer. It will be of type PersistableBundle.
Constant Value: "android.content.pm.extra.DEVELOPER_VERIFICATION_EXTENSION_RESPONSE"
EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON
public static final String EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON
When an installation fails because the developer verification was incomplete or blocked,
 this extra provides a code that explains the reason, such
 as DEVELOPER_VERIFICATION_FAILED_REASON_NETWORK_UNAVAILABLE. It is included in the
 installation result returned via the IntentSender in
 Session.commit(IntentSender). However, along with this reason code, installers can
 receive different status codes from EXTRA_STATUS depending on their target SDK and
 permission status:
 
- 
      Installers without the
      INSTALL_PACKAGESpermission but with theREQUEST_INSTALL_PACKAGESpermission and targetingAPI 36or less will first receive theSTATUS_PENDING_USER_ACTIONstatus code without this reason code. They will be forced through the user action flow to allow the OS to inform the user of such verification context before continuing to fail the install. If the user has the option to bypass the verification result and chooses to do so, the installation will proceed. Otherwise, the installer will receive theSTATUS_FAILURE_ABORTEDstatus code along with this reason code that explains why the verification had failed.
- 
     Installers with the
     INSTALL_PACKAGESpermission and targetingAPI 36or less will directly receive theSTATUS_FAILURE_ABORTEDstatus code. This is because they are not expected to have the capability of handling theSTATUS_PENDING_USER_ACTIONflow, so the installation will directly fail. This reason code will be supplied to them for providing additional information.
- 
     For all installers targeting higher than
     API 36- For situations that require user input, such as when the developer verification
     policy allows the user to bypass a verification failure caused by network issues,
     the installer will receive a STATUS_PENDING_USER_ACTIONstatus code without this reason code. The installer will be forced through the user action flow to allow the OS to inform the user of such verification context before continuing to fail the installation. If the user has the option to bypass the verification result and chooses to do so, the installation will proceed. Otherwise, the install will receive theSTATUS_FAILURE_ABORTEDstatus code along with this reason code that explains why the verification had failed.
- For all other situations, the installer will receive a
     STATUS_FAILURE_ABORTEDstatus code along with this reason code, so the installers can explain the failure to the user accordingly. AnIntent.EXTRA_INTENTwill also be populated with an intent that can provide additional context where appropriate, should the installer prefer to defer to the OS to explain the failure to the user.
 
- For situations that require user input, such as when the developer verification
     policy allows the user to bypass a verification failure caused by network issues,
     the installer will receive a 
Constant Value: "android.content.pm.extra.DEVELOPER_VERIFICATION_FAILURE_REASON"
EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED
public static final String EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED
An extra containing a boolean indicating whether the lite version of the developer
 verification was performed on the app to be installed. It is included in the installation
 result returned via the IntentSender in Session.commit(IntentSender)
 when the installation failed.
Constant Value: "android.content.pm.extra.DEVELOPER_VERIFICATION_LITE_PERFORMED"
EXTRA_INSTALL_CONSTRAINTS
public static final String EXTRA_INSTALL_CONSTRAINTS
The InstallConstraints object.
See also:
Constant Value: "android.content.pm.extra.INSTALL_CONSTRAINTS"
EXTRA_INSTALL_CONSTRAINTS_RESULT
public static final String EXTRA_INSTALL_CONSTRAINTS_RESULT
The InstallConstraintsResult object.
See also:
Constant Value: "android.content.pm.extra.INSTALL_CONSTRAINTS_RESULT"
EXTRA_OTHER_PACKAGE_NAME
public static final String EXTRA_OTHER_PACKAGE_NAME
Another package name relevant to a status. This is typically the package responsible for causing an operation failure.
See also:
Constant Value: "android.content.pm.extra.OTHER_PACKAGE_NAME"
EXTRA_PACKAGE_NAME
public static final String EXTRA_PACKAGE_NAME
Package name that an operation is working with.
See also:
Constant Value: "android.content.pm.extra.PACKAGE_NAME"
EXTRA_PRE_APPROVAL
public static final String EXTRA_PRE_APPROVAL
Indicate if the status is for a pre-approval request.
 If callers use the same IntentSender for both
 Session.requestUserPreapproval(PreapprovalDetails, IntentSender) and
 Session.commit(IntentSender), they can use this to differentiate between them.
See also:
Constant Value: "android.content.pm.extra.PRE_APPROVAL"
EXTRA_SESSION
public static final String EXTRA_SESSION
SessionInfo that an operation is working with.
See also:
Constant Value: "android.content.pm.extra.SESSION"
EXTRA_SESSION_ID
public static final String EXTRA_SESSION_ID
An integer session ID that an operation is working with.
See also:
Constant Value: "android.content.pm.extra.SESSION_ID"
EXTRA_STATUS
public static final String EXTRA_STATUS
Current status of an operation. Will be one of
 STATUS_PENDING_USER_ACTION, STATUS_SUCCESS,
 STATUS_FAILURE, STATUS_FAILURE_ABORTED,
 STATUS_FAILURE_BLOCKED, STATUS_FAILURE_CONFLICT,
 STATUS_FAILURE_INCOMPATIBLE, STATUS_FAILURE_INVALID,
 STATUS_FAILURE_STORAGE, or STATUS_FAILURE_TIMEOUT.
 
More information about a status may be available through additional extras; see the individual status documentation for details.
See also:
Constant Value: "android.content.pm.extra.STATUS"
EXTRA_STATUS_MESSAGE
public static final String EXTRA_STATUS_MESSAGE
Detailed string representation of the status, including raw details that are useful for debugging.
See also:
Constant Value: "android.content.pm.extra.STATUS_MESSAGE"
EXTRA_STORAGE_PATH
public static final String EXTRA_STORAGE_PATH
Storage path relevant to a status.
See also:
Constant Value: "android.content.pm.extra.STORAGE_PATH"
EXTRA_UNARCHIVE_ALL_USERS
public static final String EXTRA_UNARCHIVE_ALL_USERS
If true, the requestor of the unarchival has specified that the app should be unarchived
 for all users. Sent as part of the Intent.ACTION_UNARCHIVE_PACKAGE
 intent.
Constant Value: "android.content.pm.extra.UNARCHIVE_ALL_USERS"
EXTRA_UNARCHIVE_ID
public static final String EXTRA_UNARCHIVE_ID
Extra field for the unarchive ID. Sent as
 part of the Intent.ACTION_UNARCHIVE_PACKAGE intent.
Constant Value: "android.content.pm.extra.UNARCHIVE_ID"
EXTRA_UNARCHIVE_PACKAGE_NAME
public static final String EXTRA_UNARCHIVE_PACKAGE_NAME
Extra field for the package name of a package that is requested to be unarchived. Sent as
 part of the Intent.ACTION_UNARCHIVE_PACKAGE intent.
Constant Value: "android.content.pm.extra.UNARCHIVE_PACKAGE_NAME"
EXTRA_UNARCHIVE_STATUS
public static final String EXTRA_UNARCHIVE_STATUS
Current status of an unarchive operation. Will be one of
 UNARCHIVAL_OK, UNARCHIVAL_ERROR_USER_ACTION_NEEDED,
 UNARCHIVAL_ERROR_INSUFFICIENT_STORAGE, UNARCHIVAL_ERROR_NO_CONNECTIVITY,
 UNARCHIVAL_GENERIC_ERROR, UNARCHIVAL_ERROR_INSTALLER_DISABLED or
 UNARCHIVAL_ERROR_INSTALLER_UNINSTALLED.
 
 If the status is not UNARCHIVAL_OK, then Intent.EXTRA_INTENT will be set
 with an intent for a corresponding follow-up action (e.g. storage clearing dialog) or a
 failure dialog.
 
 Used as part of requestUnarchive(String, IntentSender) to return the status of the unarchival through
 the IntentSender.
See also:
Constant Value: "android.content.pm.extra.UNARCHIVE_STATUS"
PACKAGE_SOURCE_DOWNLOADED_FILE
public static final int PACKAGE_SOURCE_DOWNLOADED_FILE
Code indicating that the package being installed comes from a file that was downloaded to
 the device by the user. For use in place of PACKAGE_SOURCE_LOCAL_FILE when the
 installer knows the package was downloaded.
Constant Value: 4 (0x00000004)
PACKAGE_SOURCE_LOCAL_FILE
public static final int PACKAGE_SOURCE_LOCAL_FILE
Code indicating that the package being installed comes from a local file on the device. A file manager that is facilitating the installation of an APK file would use this.
Constant Value: 3 (0x00000003)
PACKAGE_SOURCE_OTHER
public static final int PACKAGE_SOURCE_OTHER
Code indicating that the package being installed is from a source not reflected by any other package source constant.
Constant Value: 1 (0x00000001)
PACKAGE_SOURCE_STORE
public static final int PACKAGE_SOURCE_STORE
Code indicating that the package being installed is from a store. An app store that installs an app for the user would use this.
Constant Value: 2 (0x00000002)
PACKAGE_SOURCE_UNSPECIFIED
public static final int PACKAGE_SOURCE_UNSPECIFIED
The installer did not call PackageInstaller.SessionParams.setPackageSource(int) to
 specify the package source.
Constant Value: 0 (0x00000000)
STATUS_FAILURE
public static final int STATUS_FAILURE
The operation failed in a generic way. The system will always try to provide a more specific failure reason, but in some rare cases this may be delivered.
See also:
Constant Value: 1 (0x00000001)
STATUS_FAILURE_ABORTED
public static final int STATUS_FAILURE_ABORTED
The operation failed because it was actively aborted. For example, the user actively declined requested permissions, or the session was abandoned.
See also:
Constant Value: 3 (0x00000003)
STATUS_FAILURE_BLOCKED
public static final int STATUS_FAILURE_BLOCKED
The operation failed because it was blocked. For example, a device policy may be blocking the operation, a package verifier may have blocked the operation, or the app may be required for core system operation.
 The result may also contain EXTRA_OTHER_PACKAGE_NAME with the
 specific package blocking the install.
Constant Value: 2 (0x00000002)
STATUS_FAILURE_CONFLICT
public static final int STATUS_FAILURE_CONFLICT
The operation failed because it conflicts (or is inconsistent with) with another package already installed on the device. For example, an existing permission, incompatible certificates, etc. The user may be able to uninstall another app to fix the issue.
 The result may also contain EXTRA_OTHER_PACKAGE_NAME with the
 specific package identified as the cause of the conflict.
Constant Value: 5 (0x00000005)
STATUS_FAILURE_INCOMPATIBLE
public static final int STATUS_FAILURE_INCOMPATIBLE
The operation failed because it is fundamentally incompatible with this
 device. For example, the app may require a hardware feature that doesn't
 exist, it may be missing native code for the ABIs supported by the
 device, or it requires a newer SDK version, etc.
 Starting in Build.VERSION_CODES.UPSIDE_DOWN_CAKE, an app with only 32-bit native
 code can still be installed on a device that supports both 64-bit and 32-bit ABIs.
 However, a warning dialog will be displayed when the app is launched.
See also:
Constant Value: 7 (0x00000007)
STATUS_FAILURE_INVALID
public static final int STATUS_FAILURE_INVALID
The operation failed because one or more of the APKs was invalid. For example, they might be malformed, corrupt, incorrectly signed, mismatched, etc.
See also:
Constant Value: 4 (0x00000004)
STATUS_FAILURE_STORAGE
public static final int STATUS_FAILURE_STORAGE
The operation failed because of storage issues. For example, the device may be running low on space, or external media may be unavailable. The user may be able to help free space or insert different external media.
 The result may also contain EXTRA_STORAGE_PATH with the path to
 the storage device that caused the failure.
See also:
Constant Value: 6 (0x00000006)
STATUS_FAILURE_TIMEOUT
public static final int STATUS_FAILURE_TIMEOUT
The operation failed because it didn't complete within the specified timeout.
See also:
Constant Value: 8 (0x00000008)
STATUS_PENDING_USER_ACTION
public static final int STATUS_PENDING_USER_ACTION
User action is currently required to proceed. You can launch the intent
 activity described by Intent.EXTRA_INTENT to involve the user and
 continue.
 
You may choose to immediately launch the intent if the user is actively using your app. Otherwise, you should use a notification to guide the user back into your app before launching.
See also:
Constant Value: -1 (0xffffffff)
STATUS_SUCCESS
public static final int STATUS_SUCCESS
The operation succeeded.
Constant Value: 0 (0x00000000)
UNARCHIVAL_ERROR_INSTALLER_DISABLED
public static final int UNARCHIVAL_ERROR_INSTALLER_DISABLED
The installer responsible for the unarchival is disabled.
The system will return this status if appropriate. Installers do not need to verify for this error.
Constant Value: 4 (0x00000004)
UNARCHIVAL_ERROR_INSTALLER_UNINSTALLED
public static final int UNARCHIVAL_ERROR_INSTALLER_UNINSTALLED
The installer responsible for the unarchival has been uninstalled
The system will return this status if appropriate. Installers do not need to verify for this error.
Constant Value: 5 (0x00000005)
UNARCHIVAL_ERROR_INSUFFICIENT_STORAGE
public static final int UNARCHIVAL_ERROR_INSUFFICIENT_STORAGE
Not enough storage to unarchive the application.
 The installer can optionally provide a userActionIntent for a space-clearing
 dialog. If no action is provided, then a generic intent
 StorageManager.ACTION_MANAGE_STORAGE is started instead.
Constant Value: 2 (0x00000002)
UNARCHIVAL_ERROR_NO_CONNECTIVITY
public static final int UNARCHIVAL_ERROR_NO_CONNECTIVITY
The device is not connected to the internet
Constant Value: 3 (0x00000003)
UNARCHIVAL_ERROR_USER_ACTION_NEEDED
public static final int UNARCHIVAL_ERROR_USER_ACTION_NEEDED
The user needs to interact with the installer to enable the installation.
An example use case for this could be that the user needs to login to allow the download for a paid app.
Constant Value: 1 (0x00000001)
UNARCHIVAL_GENERIC_ERROR
public static final int UNARCHIVAL_GENERIC_ERROR
Generic error: The app cannot be unarchived.
Constant Value: 100 (0x00000064)
UNARCHIVAL_OK
public static final int UNARCHIVAL_OK
The unarchival is possible and will commence.
Note that this does not mean that the unarchival has completed. This status should be sent before any longer asynchronous action (e.g. app download) is started.
Constant Value: 0 (0x00000000)
Public methods
abandonSession
public void abandonSession (int sessionId)
Completely abandon the given session, destroying all staged data and
 rendering it invalid. Abandoned sessions will be reported to
 SessionCallback listeners as failures. This is equivalent to
 opening the session and calling Session.abandon().
| Parameters | |
|---|---|
| sessionId | int | 
| Throws | |
|---|---|
| SecurityException | when the caller does not own the session, or the session is invalid. | 
checkInstallConstraints
public void checkInstallConstraints (List<String> packageNames, PackageInstaller.InstallConstraints constraints, Executor executor, Consumer<PackageInstaller.InstallConstraintsResult> callback)
Check if install constraints are satisfied for the given packages. Note this query result is just a hint and subject to race because system states could change anytime in-between this query and committing the session. The result is returned by a callback because some constraints might take a long time to evaluate.
| Parameters | |
|---|---|
| packageNames | List: a list of package names to check the constraints for installation
 This value cannot benull. | 
| constraints | PackageInstaller.InstallConstraints: the constraints for installation.
 This value cannot benull. | 
| executor | Executor: theExecutoron which to invoke the callback
 This value cannot benull.
 Callback and listener events are dispatched through thisExecutor, providing an easy way to control which thread is
 used. To dispatch events through the main thread of your
 application, you can useContext.getMainExecutor().
 Otherwise, provide anExecutorthat dispatches to an appropriate thread. | 
| callback | Consumer: called when theInstallConstraintsResultis ready
 This value cannot benull. | 
| Throws | |
|---|---|
| SecurityException | if the given packages' installer of record doesn't match the caller's own package name or the installerPackageName set by the caller doesn't match the caller's own package name. | 
commitSessionAfterInstallConstraintsAreMet
public void commitSessionAfterInstallConstraintsAreMet (int sessionId, 
                IntentSender statusReceiver, 
                PackageInstaller.InstallConstraints constraints, 
                long timeoutMillis)Commit the session when all constraints are satisfied. This is a convenient method to
 combine waitForInstallConstraints(java.util.List, android.content.pm.PackageInstaller.InstallConstraints, android.content.IntentSender, long)
 and Session.commit(IntentSender).
 
 Once this method is called, the session is sealed and no additional mutations
 may be performed on the session. In the case of timeout, you may commit the
 session again using this method or Session.commit(IntentSender) for retries.
| Parameters | |
|---|---|
| sessionId | int: the session ID to commit when all constraints are satisfied. | 
| statusReceiver | IntentSender: Called when the state of the session changes. Intents
                       sent to this receiver containEXTRA_STATUS.
                       Refer to the individual status codes on how to handle them.
 This value cannot benull. | 
| constraints | PackageInstaller.InstallConstraints: The requirements to satisfy before committing the session.
 This value cannot benull. | 
| timeoutMillis | long: The maximum time to wait, in milliseconds until the
                      constraints are satisfied. The caller will be notified viastatusReceiverif timeout happens before commit.
 Value is a non-negative duration in milliseconds. | 
| Throws | |
|---|---|
| IllegalArgumentException | if the statusReceiverfrom an immutablePendingIntentwhen caller has a target SDK of API
             35 or above. | 
createSession
public int createSession (PackageInstaller.SessionParams params)
Create a new session using the given parameters, returning a unique ID that represents the session. Once created, the session can be opened multiple times across multiple device boots.
The system may automatically destroy sessions that have not been finalized (either committed or abandoned) within a reasonable period of time, typically on the order of a day.
| Parameters | |
|---|---|
| params | PackageInstaller.SessionParams: This value cannot benull. | 
| Returns | |
|---|---|
| int | positive, non-zero unique ID that represents the created session. This ID remains consistent across device reboots until the session is finalized. IDs are not reused during a given boot. | 
| Throws | |
|---|---|
| IOException | if parameters were unsatisfiable, such as lack of disk space or unavailable media. | 
| SecurityException | when installation services are unavailable, such as when called from a restricted user. | 
| IllegalArgumentException | when SessionParamsis invalid. | 
getActiveStagedSession
public PackageInstaller.SessionInfo getActiveStagedSession ()
      This method was deprecated
      in API level 30.
    Use getActiveStagedSessions() as there can be more than one active staged
 session
  
Returns first active staged session, or null if there is none.
 
For more information on what sessions are considered active see
 SessionInfo.isStagedSessionActive().
| Returns | |
|---|---|
| PackageInstaller.SessionInfo | |
getActiveStagedSessions
public List<PackageInstaller.SessionInfo> getActiveStagedSessions ()
Returns list of active staged sessions. Returns empty list if there is none.
For more information on what sessions are considered active see
      * SessionInfo.isStagedSessionActive().
| Returns | |
|---|---|
| List<PackageInstaller.SessionInfo> | This value cannot be null. | 
getAllSessions
public List<PackageInstaller.SessionInfo> getAllSessions ()
Return list of all known install sessions, regardless of the installer. Callers need to either declare <queries> element with the specific package name in the app's manifest, have the android.permission.QUERY_ALL_PACKAGES, or be the session owner to retrieve these details.
| Returns | |
|---|---|
| List<PackageInstaller.SessionInfo> | This value cannot be null. | 
getDeveloperVerificationServiceProvider
public final ComponentName getDeveloperVerificationServiceProvider ()
Return the component name of the developer verification service provider, for the purpose of interacting with the specific verifier in relation to extension parameters and response structure. Return null if the system verifier service provider is not available to the caller, or if there is no such provider specified by the system.
| Returns | |
|---|---|
| ComponentName | |
getMySessions
public List<PackageInstaller.SessionInfo> getMySessions ()
Return list of all known install sessions owned by the calling app.
| Returns | |
|---|---|
| List<PackageInstaller.SessionInfo> | This value cannot be null. | 
getSessionInfo
public PackageInstaller.SessionInfo getSessionInfo (int sessionId)
Return details for a specific session. Callers need to either declare <queries> element with the specific package name in the app's manifest, have the android.permission.QUERY_ALL_PACKAGES, or be the session owner to retrieve these details.
| Parameters | |
|---|---|
| sessionId | int | 
| Returns | |
|---|---|
| PackageInstaller.SessionInfo | details for the requested session, or nullif the session
         does not exist. | 
getStagedSessions
public List<PackageInstaller.SessionInfo> getStagedSessions ()
Return list of all staged install sessions. Callers need to either declare <queries> element with the specific package name in the app's manifest, have the android.permission.QUERY_ALL_PACKAGES, or be the session owner to retrieve these details.
| Returns | |
|---|---|
| List<PackageInstaller.SessionInfo> | This value cannot be null. | 
installExistingPackage
public void installExistingPackage (String packageName, int installReason, IntentSender statusReceiver)
Install the given package, which already exists on the device, for the user for which this installer was created.
This will
 all restricted permissions.
 
 Requires Manifest.permission.INSTALL_PACKAGES and android.Manifest.permission.INSTALL_EXISTING_PACKAGES
| Parameters | |
|---|---|
| packageName | String: The package to install.
 This value cannot benull. | 
| installReason | int: Reason for install.
 Value isPackageManager.INSTALL_REASON_UNKNOWN,PackageManager.INSTALL_REASON_POLICY,PackageManager.INSTALL_REASON_DEVICE_RESTORE,PackageManager.INSTALL_REASON_DEVICE_SETUP,PackageManager.INSTALL_REASON_USER, or android.content.pm.PackageManager.INSTALL_REASON_ROLLBACK | 
| statusReceiver | IntentSender: Where to deliver the result of the operation indicated by the extraEXTRA_STATUS. Refer to the individual status codes
                       on how to handle them.
 This value may benull. | 
installPackageArchived
public void installPackageArchived (ArchivedPackageInfo archivedPackageInfo, PackageInstaller.SessionParams sessionParams, IntentSender statusReceiver)
Install package in an archived state.
 
 Requires Manifest.permission.INSTALL_PACKAGES
| Parameters | |
|---|---|
| archivedPackageInfo | ArchivedPackageInfo: archived package data such as package name, signature etc.
 This value cannot benull. | 
| sessionParams | PackageInstaller.SessionParams: used to create an underlying installation session
 This value cannot benull. | 
| statusReceiver | IntentSender: Called when the state of the session changes. Intents
                       sent to this receiver containEXTRA_STATUS. Refer to the
                       individual status codes on how to handle them.
 This value cannot benull. | 
openSession
public PackageInstaller.Session openSession (int sessionId)
Open an existing session to actively perform work. To succeed, the caller must be the owner of the install session.
| Parameters | |
|---|---|
| sessionId | int | 
| Returns | |
|---|---|
| PackageInstaller.Session | This value cannot be null. | 
| Throws | |
|---|---|
| IOException | if parameters were unsatisfiable, such as lack of disk space or unavailable media. | 
| SecurityException | when the caller does not own the session, or the session is invalid. | 
registerSessionCallback
public void registerSessionCallback (PackageInstaller.SessionCallback callback, Handler handler)
Register to watch for session lifecycle events. No special permissions are required to watch for these events.
| Parameters | |
|---|---|
| callback | PackageInstaller.SessionCallback: This value cannot benull. | 
| handler | Handler: to dispatch callback events through, otherwise uses
            calling thread.
 This value cannot benull. | 
registerSessionCallback
public void registerSessionCallback (PackageInstaller.SessionCallback callback)
Register to watch for session lifecycle events. The callers need to be the session owner or have the android.permission.QUERY_ALL_PACKAGES to watch for these events.
| Parameters | |
|---|---|
| callback | PackageInstaller.SessionCallback: This value cannot benull. | 
reportUnarchivalState
public void reportUnarchivalState (PackageInstaller.UnarchivalState unarchivalState)
Reports the state of an unarchival to the system.
 
 Requires Manifest.permission.INSTALL_PACKAGES or Manifest.permission.REQUEST_INSTALL_PACKAGES
| Parameters | |
|---|---|
| unarchivalState | PackageInstaller.UnarchivalState: This value cannot benull. | 
| Throws | |
|---|---|
| PackageManager.NameNotFoundException | if no unarchival with unarchiveIdexists | 
See also:
reportUnarchivalStatus
public void reportUnarchivalStatus (int unarchiveId, 
                int status, 
                long requiredStorageBytes, 
                PendingIntent userActionIntent)Reports the status of an unarchival to the system.
 
 Requires Manifest.permission.INSTALL_PACKAGES or Manifest.permission.REQUEST_INSTALL_PACKAGES
| Parameters | |
|---|---|
| unarchiveId | int: the ID provided by the system as part of the
                             intent.action.UNARCHIVE broadcast with EXTRA_UNARCHIVE_ID. | 
| status | int: is used for the system to provide the user with necessary
                             follow-up steps or errors.
 Value is android.content.pm.PackageInstaller.UNARCHIVAL_STATUS_UNSET,UNARCHIVAL_OK,UNARCHIVAL_ERROR_USER_ACTION_NEEDED,UNARCHIVAL_ERROR_INSUFFICIENT_STORAGE,UNARCHIVAL_ERROR_NO_CONNECTIVITY,UNARCHIVAL_ERROR_INSTALLER_DISABLED,UNARCHIVAL_ERROR_INSTALLER_UNINSTALLED, orUNARCHIVAL_GENERIC_ERROR | 
| requiredStorageBytes | long: If the error is UNARCHIVAL_ERROR_INSUFFICIENT_STORAGE this field
                             should be set to specify how many additional bytes of storage
                             are required to unarchive the app. | 
| userActionIntent | PendingIntent: Optional intent to start a follow up action required to
                             facilitate the unarchival flow (e.g. user needs to log in).
 This value may benull. | 
| Throws | |
|---|---|
| PackageManager.NameNotFoundException | if no unarchival with unarchiveIdexists | 
requestArchive
public void requestArchive (String packageName, IntentSender statusReceiver)
Requests to archive a package which is currently installed.
 During the archival process, the apps APKs and cache are removed from the device while
 the user data is kept. Through the requestUnarchive(String, IntentSender) call, apps
 can be restored again through their responsible installer.
 
 Archived apps are returned as displayable apps through the LauncherApps APIs and
 will be displayed to users with UI treatment to highlight that said apps are archived. If
 a user taps on an archived app, the app will be unarchived and the restoration process is
 communicated.
 
 Requires Manifest.permission.DELETE_PACKAGES or Manifest.permission.REQUEST_DELETE_PACKAGES
| Parameters | |
|---|---|
| packageName | String: This value cannot benull. | 
| statusReceiver | IntentSender: Callback used to notify when the operation is completed.
 This value cannot benull. | 
| Throws | |
|---|---|
| PackageManager.NameNotFoundException | If packageNameisn't found or not
                                              available to the caller or isn't archived. | 
requestUnarchive
public void requestUnarchive (String packageName, IntentSender statusReceiver)
Requests to unarchive a currently archived package.
 Sends a request to unarchive an app to the responsible installer. The installer is
 determined by InstallSourceInfo.getUpdateOwnerPackageName(), or
 InstallSourceInfo.getInstallingPackageName() if the former value is null.
 
 The installation will happen asynchronously and can be observed through
 Intent.ACTION_PACKAGE_ADDED.
 
 Requires Manifest.permission.INSTALL_PACKAGES or Manifest.permission.REQUEST_INSTALL_PACKAGES
| Parameters | |
|---|---|
| packageName | String: This value cannot benull. | 
| statusReceiver | IntentSender: Callback used to notify whether the installer has accepted the
                       unarchival request or an error has occurred. The status update will be
                       sent thoughEXTRA_UNARCHIVE_STATUS. Only one status will be
                       sent.
 This value cannot benull. | 
| Throws | |
|---|---|
| PackageManager.NameNotFoundException | If packageNameisn't found or not
                                              visible to the caller or if the package has no
                                              installer on the device anymore to unarchive it. | 
| IOException | If parameters were unsatisfiable, such as lack of disk space. | 
uninstall
public void uninstall (String packageName, IntentSender statusReceiver)
Uninstall the given package, removing it completely from the device. This method is available to:
- the current "installer of record" for the package
- the device owner
- the affiliated profile owner
Requires
Manifest.permission.DELETE_PACKAGES or Manifest.permission.REQUEST_DELETE_PACKAGES
    | Parameters | |
|---|---|
| packageName | String: The package to uninstall.
 This value cannot benull. | 
| statusReceiver | IntentSender: Where to deliver the result of the operation indicated by the extraEXTRA_STATUS. Refer to the individual status codes
                       on how to handle them.
 This value cannot benull. | 
See also:
uninstall
public void uninstall (VersionedPackage versionedPackage, int flags, IntentSender statusReceiver)
Uninstall the given package with a specific version code, removing it
 completely from the device. This method is only available to the current
 "installer of record" for the package. If the version code of the package
 does not match the one passed in the versioned package argument this
 method is a no-op. Use PackageManager.VERSION_CODE_HIGHEST to
 uninstall the latest version of the package.
 
 Requires Manifest.permission.DELETE_PACKAGES or Manifest.permission.REQUEST_DELETE_PACKAGES
| Parameters | |
|---|---|
| versionedPackage | VersionedPackage: The versioned package to uninstall.
 This value cannot benull. | 
| flags | int: Flags for uninstall.
 Value is either0or a combination of android.content.pm.PackageManager.DELETE_KEEP_DATA, android.content.pm.PackageManager.DELETE_ALL_USERS, android.content.pm.PackageManager.DELETE_SYSTEM_APP, android.content.pm.PackageManager.DELETE_DONT_KILL_APP, and android.content.pm.PackageManager.DELETE_CHATTY | 
| statusReceiver | IntentSender: Where to deliver the result of the operation indicated by the extraEXTRA_STATUS. Refer to the individual status codes
                       on how to handle them.
 This value cannot benull. | 
uninstall
public void uninstall (VersionedPackage versionedPackage, IntentSender statusReceiver)
Uninstall the given package with a specific version code, removing it
 completely from the device. If the version code of the package
 does not match the one passed in the versioned package argument this
 method is a no-op. Use PackageManager.VERSION_CODE_HIGHEST to
 uninstall the latest version of the package.
 
This method is available to:
- the current "installer of record" for the package
- the device owner
- the affiliated profile owner
Requires
Manifest.permission.DELETE_PACKAGES or Manifest.permission.REQUEST_DELETE_PACKAGES
    | Parameters | |
|---|---|
| versionedPackage | VersionedPackage: The versioned package to uninstall.
 This value cannot benull. | 
| statusReceiver | IntentSender: Where to deliver the result of the operation indicated by the extraEXTRA_STATUS. Refer to the individual status codes
                       on how to handle them.
 This value cannot benull. | 
See also:
uninstallExistingPackage
public void uninstallExistingPackage (String packageName, IntentSender statusReceiver)
Uninstall the given package for the user for which this installer was created if the package
 will still exist for other users on the device.
 
 Requires Manifest.permission.DELETE_PACKAGES
| Parameters | |
|---|---|
| packageName | String: The package to uninstall.
 This value cannot benull. | 
| statusReceiver | IntentSender: Where to deliver the result of the operation indicated by the extraEXTRA_STATUS. Refer to the individual status codes
                       on how to handle them.
 This value may benull. | 
unregisterSessionCallback
public void unregisterSessionCallback (PackageInstaller.SessionCallback callback)
Unregister a previously registered callback.
| Parameters | |
|---|---|
| callback | PackageInstaller.SessionCallback: This value cannot benull. | 
updateSessionAppIcon
public void updateSessionAppIcon (int sessionId, 
                Bitmap appIcon)Update the icon representing the app being installed in a specific
 session. This should be roughly
 ActivityManager.getLauncherLargeIconSize() in both dimensions.
| Parameters | |
|---|---|
| sessionId | int | 
| appIcon | Bitmap: This value may benull. | 
| Throws | |
|---|---|
| SecurityException | when the caller does not own the session, or the session is invalid. | 
updateSessionAppLabel
public void updateSessionAppLabel (int sessionId, 
                CharSequence appLabel)Update the label representing the app being installed in a specific session.
| Parameters | |
|---|---|
| sessionId | int | 
| appLabel | CharSequence: This value may benull. | 
| Throws | |
|---|---|
| SecurityException | when the caller does not own the session, or the session is invalid. | 
waitForInstallConstraints
public void waitForInstallConstraints (List<String> packageNames, PackageInstaller.InstallConstraints constraints, IntentSender callback, long timeoutMillis)
Similar to checkInstallConstraints(java.util.List, android.content.pm.PackageInstaller.InstallConstraints, java.util.concurrent.Executor, java.util.function.Consumer),
 but the callback is invoked only when the constraints are satisfied or after timeout.
 
Note: the device idle constraint might take a long time to evaluate. The system will ensure the constraint is evaluated completely before handling timeout.
| Parameters | |
|---|---|
| packageNames | List: a list of package names to check the constraints for installation
 This value cannot benull. | 
| constraints | PackageInstaller.InstallConstraints: the constraints for installation.
 This value cannot benull. | 
| callback | IntentSender: Called when the constraints are satisfied or after timeout.
                 Intents sent to this callback contain:Intent.EXTRA_PACKAGESfor the input package names,EXTRA_INSTALL_CONSTRAINTSfor the input constraints,EXTRA_INSTALL_CONSTRAINTS_RESULTfor the result.
 This value cannot benull. | 
| timeoutMillis | long: The maximum time to wait, in milliseconds until the constraints are
                      satisfied. Valid range is from 0 to one week.0means the
                      callback will be invoked immediately no matter constraints are
                      satisfied or not.
 Value is a non-negative duration in milliseconds. | 
| Throws | |
|---|---|
| SecurityException | if the given packages' installer of record doesn't match the caller's own package name or the installerPackageName set by the caller doesn't match the caller's own package name. | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-10-15 UTC.
