Click or drag to resize

PackageInstallerSessionUpgrade Method

Call this method to upgrade an application installed on the device.

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 Upgrade (string apk);

Parameters

apk
Type: System.String
String full path of the .apk to be used to upgrade the application already installed with the same Package Name of this .apk. NOTE : Running on an Android 11 device, until Datalogic SDK v1.32, an user App can upgrade 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 upgrade 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 upgrade an APK stored into the internal memory of the calling App.

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 upgrade an application installed on the device.
The method must be called after having called the openSession().
The method is queued internally and executed 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.upgrade("/dir1/dir11/dir116/pkg1_v2.apk");
session.closeSession();

[Android Documentation]

See Also

Reference