Dela via


PackageInstaller Class

Definition

Offers the ability to install, upgrade, and remove applications on the device.

[Android.Runtime.Register("android/content/pm/PackageInstaller", DoNotGenerateAcw=true)]
public class PackageInstaller : Java.Lang.Object
[<Android.Runtime.Register("android/content/pm/PackageInstaller", DoNotGenerateAcw=true)>]
type PackageInstaller = class
    inherit Object
Inheritance
PackageInstaller
Attributes

Remarks

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. <ul> <li>the device owner <li>the affiliated profile owner </ul>

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: <ul> <li>All APKs must have the exact same package name, version code, and signing certificates. <li>All APKs must have unique split names. <li>All installations must contain a single base APK. </ul>

The ApiDemos project contains examples of using this API: ApiDemos/src/com/example/android/apis/content/InstallApk*.java.

Java documentation for android.content.pm.PackageInstaller.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

PackageInstaller(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionSessionCommitted

Broadcast Action: Explicit broadcast sent to the last known default launcher when a session for a new install is committed.

ActionSessionDetails

Activity Action: Show details about a particular install session.

ActionSessionUpdated

Broadcast Action: Send information about a staged install session when its state is updated.

ExtraInstallConstraints

The InstallConstraints object.

ExtraInstallConstraintsResult

The InstallConstraintsResult object.

ExtraOtherPackageName

Another package name relevant to a status.

ExtraPackageName

Package name that an operation is working with.

ExtraPreApproval

Indicate if the status is for a pre-approval request.

ExtraSession

SessionInfo that an operation is working with.

ExtraSessionId

An integer session ID that an operation is working with.

ExtraStatus

Current status of an operation.

ExtraStatusMessage

Detailed string representation of the status, including raw details that are useful for debugging.

ExtraStoragePath

Storage path relevant to a status.

PackageSourceDownloadedFile
Obsolete.

Code indicating that the package being installed comes from a file that was downloaded to the device by the user.

PackageSourceLocalFile
Obsolete.

Code indicating that the package being installed comes from a local file on the device.

PackageSourceOther
Obsolete.

Code indicating that the package being installed is from a source not reflected by any other package source constant.

PackageSourceStore
Obsolete.

Code indicating that the package being installed is from a store.

PackageSourceUnspecified
Obsolete.

The installer did not call PackageInstaller.SessionParams#setPackageSource(int) to specify the package source.

StatusFailureTimeout
Obsolete.

The operation failed because it didn't complete within the specified timeout.

Properties

ActiveStagedSession

Returns first active staged session, or null if there is none.

ActiveStagedSessions

Returns list of active staged sessions.

AllSessions

Return list of all known install sessions, regardless of the installer.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MySessions

Return list of all known install sessions owned by the calling app.

PeerReference (Inherited from Object)
StagedSessions

Return list of all staged install sessions.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AbandonSession(Int32)

Completely abandon the given session, destroying all staged data and rendering it invalid.

CheckInstallConstraints(IList<String>, PackageInstaller+InstallConstraints, IExecutor, IConsumer)
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CommitSessionAfterInstallConstraintsAreMet(Int32, IntentSender, PackageInstaller+InstallConstraints, Int64)
CreateSession(PackageInstaller+SessionParams)

Create a new session using the given parameters, returning a unique ID that represents the session.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetSessionInfo(Int32)

Return details for a specific session.

InstallExistingPackage(String, InstallReason, IntentSender)

Install the given package, which already exists on the device, for the user for which this installer was created.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OpenSession(Int32)

Open an existing session to actively perform work.

RegisterSessionCallback(PackageInstaller+SessionCallback, Handler)

Register to watch for session lifecycle events.

RegisterSessionCallback(PackageInstaller+SessionCallback)

Register to watch for session lifecycle events.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Uninstall(String, IntentSender)

Uninstall the given package, removing it completely from the device.

Uninstall(VersionedPackage, Int32, IntentSender)

Uninstall the given package with a specific version code, removing it completely from the device.

Uninstall(VersionedPackage, IntentSender)

Uninstall the given package with a specific version code, removing it completely from the device.

UninstallExistingPackage(String, IntentSender)

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.

UnregisterFromRuntime() (Inherited from Object)
UnregisterSessionCallback(PackageInstaller+SessionCallback)

Unregister a previously registered callback.

UpdateSessionAppIcon(Int32, Bitmap)

Update the icon representing the app being installed in a specific session.

UpdateSessionAppLabel(Int32, ICharSequence)

Update the label representing the app being installed in a specific session.

UpdateSessionAppLabel(Int32, String)

Update the label representing the app being installed in a specific session.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WaitForInstallConstraints(IList<String>, PackageInstaller+InstallConstraints, IntentSender, Int64)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to