Skip to content

Most visited

Recently visited

navigation

PackageInstaller.SessionParams

public static class PackageInstaller.SessionParams
extends Object implements Parcelable

java.lang.Object
   ↳ android.content.pm.PackageInstaller.SessionParams


Parameters for creating a new PackageInstaller.Session.

Summary

Constants

int MODE_FULL_INSTALL

Mode for an install session whose staged APKs should fully replace any existing APKs for the target app.

int MODE_INHERIT_EXISTING

Mode for an install session that should inherit any existing APKs for the target app, unless they have been explicitly overridden (based on split name) by the session.

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<PackageInstaller.SessionParams> CREATOR

Public constructors

PackageInstaller.SessionParams(int mode)

Construct parameters for a new package install session.

Public methods

int describeContents()

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

void setAppIcon(Bitmap appIcon)

Optionally set an icon representing the app being installed.

void setAppLabel(CharSequence appLabel)

Optionally set a label representing the app being installed.

void setAppPackageName(String appPackageName)

Optionally set the package name of the app being installed.

void setInstallLocation(int installLocation)

Provide value of installLocation, which may be used to determine where the app will be staged.

void setInstallReason(int installReason)

Set the reason for installing this package.

void setOriginatingUid(int originatingUid)

Sets the UID that initiated package installation.

void setOriginatingUri(Uri originatingUri)

Optionally set the URI where this package was downloaded from.

void setReferrerUri(Uri referrerUri)

Optionally set the URI that referred you to install this package.

void setSize(long sizeBytes)

Optionally indicate the total size (in bytes) of all APKs that will be delivered in this session.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

MODE_FULL_INSTALL

added in API level 21
int MODE_FULL_INSTALL

Mode for an install session whose staged APKs should fully replace any existing APKs for the target app.

Constant Value: 1 (0x00000001)

MODE_INHERIT_EXISTING

added in API level 21
int MODE_INHERIT_EXISTING

Mode for an install session that should inherit any existing APKs for the target app, unless they have been explicitly overridden (based on split name) by the session. For example, this can be used to add one or more split APKs to an existing installation.

If there are no existing APKs for the target app, this behaves like MODE_FULL_INSTALL.

Constant Value: 2 (0x00000002)

Fields

Public constructors

PackageInstaller.SessionParams

added in API level 21
PackageInstaller.SessionParams (int mode)

Construct parameters for a new package install session.

Parameters
mode int: one of MODE_FULL_INSTALL or MODE_INHERIT_EXISTING describing how the session should interact with an existing app.

Public methods

describeContents

added in API level 21
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(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.

setAppIcon

added in API level 21
void setAppIcon (Bitmap appIcon)

Optionally set an icon representing the app being installed. This should be roughly getLauncherLargeIconSize() in both dimensions.

Parameters
appIcon Bitmap

This value may be null.

setAppLabel

added in API level 21
void setAppLabel (CharSequence appLabel)

Optionally set a label representing the app being installed.

Parameters
appLabel CharSequence

This value may be null.

setAppPackageName

added in API level 21
void setAppPackageName (String appPackageName)

Optionally set the package name of the app being installed. It's strongly recommended that you provide this value when known, so that observers can communicate installing apps to users.

If the APKs staged in the session aren't consistent with this package name, the install will fail. Regardless of this value, all APKs in the app must have the same package name.

Parameters
appPackageName String

This value may be null.

setInstallLocation

added in API level 21
void setInstallLocation (int installLocation)

Provide value of installLocation, which may be used to determine where the app will be staged. Defaults to INSTALL_LOCATION_INTERNAL_ONLY.

Parameters
installLocation int

setInstallReason

void setInstallReason (int installReason)

Set the reason for installing this package.

Parameters
installReason int

Value is INSTALL_REASON_UNKNOWN, INSTALL_REASON_POLICY, INSTALL_REASON_DEVICE_RESTORE, INSTALL_REASON_DEVICE_SETUP or INSTALL_REASON_USER.

setOriginatingUid

added in API level 24
void setOriginatingUid (int originatingUid)

Sets the UID that initiated package installation. This is informational and may be used as a signal for anti-malware purposes.

Parameters
originatingUid int

See also:

setOriginatingUri

added in API level 21
void setOriginatingUri (Uri originatingUri)

Optionally set the URI where this package was downloaded from. This is informational and may be used as a signal for anti-malware purposes.

Parameters
originatingUri Uri

This value may be null.

See also:

setReferrerUri

added in API level 21
void setReferrerUri (Uri referrerUri)

Optionally set the URI that referred you to install this package. This is informational and may be used as a signal for anti-malware purposes.

Parameters
referrerUri Uri

This value may be null.

See also:

setSize

added in API level 21
void setSize (long sizeBytes)

Optionally indicate the total size (in bytes) of all APKs that will be delivered in this session. The system may use this to ensure enough disk space exists before proceeding, or to estimate container size for installations living on external storage.

Parameters
sizeBytes long

See also:

writeToParcel

added in API level 21
void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.