Click or drag to resize

PackageInstaller Class

To install an application do the following steps:
  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Obtain an instance of IPackageInstallerListener that will be used to handle the result of the command. This object must be passed as parameter to the install method. -
  3. To perform the install session call [!:Com.Datalogic.Device.App.PackageInstaller.install(java.lang.String,%20boolean,%20com.datalogic.device.app.PackageInstallerListener)]. The method onResult of the listener will be called when the install session has completely finished, either with success or failure. -
Inheritance Hierarchy
Object
  Com.Datalogic.Device.AppPackageInstaller

Namespace:  Com.Datalogic.Device.App
Assembly:  datalogic-xamarin-sdk (in datalogic-xamarin-sdk.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class PackageInstaller : Object

The PackageInstaller type exposes the following members.

Constructors
  NameDescription
Public methodPackageInstaller
Initializes a new instance of the PackageInstaller class
Top
Properties
  NameDescription
Public propertyJniPeerMembers
To be added.
Top
Methods
  NameDescription
Public methodCreateSession
Call this method to create a PackageInstallerSession
Public methodInstall(IListString, Boolean, IPackageInstallerListener)
Call this method to install the applications contained within the .apk files specified by apks.
Public methodInstall(String, Boolean, IPackageInstallerListener)
Call this method to install the application contained within the .apk file specified by apk.
Public methodSelfUpgrade
Call this method to upgrade the current application.
Public methodUninstall
Call this method to unistall an application installed on the device.
Public methodUpgrade
Call this method to upgrade an application installed on the device.
Top
Remarks
PackageInstaller gives developers the ability to install, uninstall and upgrade applications in unattended/silent mode. The install/uninstall/upgrade/selfUpgrade methods are asynchronous. An object that implements PackageInstallerListener must be passed to PackageInstaller to be able to handle the result.
An install/uninstall/upgrade method can be executed alone calling the corresponding method of the PackageInstaller or together with other methods grouped in a PackageInstallerSession. In the former case there will be a result callback for each method, in the latter case there will be only one callback listing the results of each method. The methods grouped in a PackageInstallerSession are executed in best effort.

To install an application do the following steps:

  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Obtain an instance of IPackageInstallerListener that will be used to handle the result of the command. This object must be passed as parameter to the install method. -
  3. To perform the install session call [!:Com.Datalogic.Device.App.PackageInstaller.install(java.lang.String,%20boolean,%20com.datalogic.device.app.PackageInstallerListener)]. The method onResult of the listener will be called when the install session has completely finished, either with success or failure. -

To uninstall an application do the following steps:

  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Obtain an instance of IPackageInstallerListener that will be used to handle the result of the command. This object must be passed as parameter to the uninstall method. -
  3. To perform the uninstall session call [!:Com.Datalogic.Device.App.PackageInstaller.uninstall(java.lang.String,%20com.datalogic.device.app.PackageInstallerListener)]. The method onResult of the listener will be called when the uninstall session has completely finished, either with success or failure. -

To upgrade an application do the following steps:

  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Obtain an instance of IPackageInstallerListener that will be used to handle the result of the command. This object must be passed as parameter to the upgrade method. -
  3. To perform the upgrade session call [!:Com.Datalogic.Device.App.PackageInstaller.upgrade(java.lang.String,%20com.datalogic.device.app.PackageInstallerListener)]. The method onResult of the listener will be called when the upgrade session has completely finished, either with success or failure. -

To execute more install/uninstall/upgrade methods and be notified of the results when all the methods have completed, do the following steps:

  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Obtain an instance of IPackageInstallerListener that will be used to handle the result of the commands. This object must be passed as parameter to the createSession method. -
  3. Obtain an instance of PackageInstallerSession with CreateSession(IPackageInstallerListener). -
  4. Open a transaction on the session calling OpenSession. -
  5. Call the methods [!:Com.Datalogic.Device.App.PackageInstallerSession.install(java.lang.String,%20boolean)], Uninstall(String), Upgrade(String) that suite you. -
  6. Close and commit the transaction on the session calling CloseSession. -
  7. The method onResult of the listener will be called when all the methods listed in the session have completed, either with success or failure. -

To upgrade the current application do the following steps:

  1. Obtain an instance of PackageInstaller with [!:Com.Datalogic.Device.App.PackageInstaller.PackageInstaller(Context)]. -
  2. Call SelfUpgrade(String) passing as parameter the name of the package to be used to upgrade the current application. -

[Android Documentation]

See Also