Click or drag to resize

PackageInstallerInstall Method (String, Boolean, IPackageInstallerListener)

Call this method to install the application contained within the .apk file specified by apk.

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 virtual int Install(
	string apk,
	bool force,
	IPackageInstallerListener listener
)

Parameters

apk
Type: SystemString
- String full path of the .apk to be installed.
force
Type: SystemBoolean
- boolean true force the upgrade in case the application is already installed, otherwise the upgrade is refused.
listener
Type: Com.Datalogic.Device.AppIPackageInstallerListener
- IPackageInstallerListener instance that implements the method [M:Com.Datalogic.Device.App.IPackageInstallerListener.OnResult(System.Collections.Generic.IList`1)] to handle the result of the method.

Return Value

Type: Int32
intSuccess in case of success, otherwise a possible error code, matching one of the PackageInstallerException error constants.
Exceptions
ExceptionCondition
PackageInstallerException - in case of error, when exceptions are enabled through the ErrorManager singleton.
Remarks

Call this method to install the application contained within the .apk file specified by apk.

The method is executed alone, not grouped together with other methods as can be done using a PackageInstallerSession

. The result of the command is received through the listener method [M:Com.Datalogic.Device.App.IPackageInstallerListener.OnResult(System.Collections.Generic.IList`1)]

. Do not suspend the UIThread while waiting for the result of the method otherwise an application’s deadlock can occur.


Example:


PackageInstaller packageInstaller = new PackageInstaller(context);

PackageInstallerListener listener = new PackageInstallerListener{public void onResult(List results) {...}};

packageInstaller.install("/dir1/dir11/dir116/pkg1.apk", false, listener);

[Android Documentation]

See Also