Click or drag to resize

PackageInstallerSessionInstall Method

Call this method to install the application contained within the .

Namespace:  Com.Datalogic.Decode
Assembly:  datalogic-xamarin-sdk (in datalogic-xamarin-sdk.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
VB
public virtual int Install (string apk, bool force);

Parameters

apk
Type: System.String
String full path of the .apk to be installed. NOTE : Running on an Android 11 device, until Datalogic SDK v1.32, an user App can install an APK only using a path of the external storage (WRITE_EXTERNAL_STORAGE permission to be granted by App to store the APK) or any path not requiring memory permissions to access (e.g Downloads). On the contrary, if the calling App stores the APK into the internal memory, the API will be not able to install the APK due to the missing privilages for accessing to the internal memory of the calling App. From Datalogic SDK v1.33, instead, the API is able to install an APK stored into the internal memory of the calling App.
force
Type: System.Boolean
boolean true force the upgrade in case the application is already installed, otherwise the upgrade is refused.

Return Value

Type: System.Int32
int PackageInstallerException.SUCCESS in case of success, otherwise a possible error code, matching one of the PackageInstallerException error constants.

Exceptions
Exception Condition
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 must be called after having called the openSession().
The method is queued internally and executed only when the closeSession() is called.
The result of the command is received through the listener method PackageInstallerListener.onResult(java.util.List<com.datalogic.device.app.PackageInstallerResult>).

Example:

PackageInstaller packageInstaller = new PackageInstaller(context);
PackageInstallerListener listener = new PackageInstallerListener{public void onResult(List results) {...}};
PackageInstallerSession session = packageInstaller.createSession(listener);
session.openSession();
session.install("/dir1/dir11/dir116/pkg1.apk", force);
session.closeSession();

[Android Documentation]

See Also

Reference