public class

AppManager

extends Object
java.lang.Object
   ↳ com.datalogic.device.app.AppManager

Class Overview

AppManager gives developers the ability to manage installed apllications.

Summary

Public Constructors
AppManager(Context context)
This is the constructor of AppManager.
Public Methods
int addBatteryOptimizationExemption(String packageName)
Call this method to place the given application package on the device's power allowlist.
int forceStopPackage(String packageName)
Call this method to stop an application.
int grantAllPermissions(String packageName)
Call this method to grant an application all the permissions declared in its manifest.
int grantPermissions(String packageName, ArrayList<String> permissions)
Call this method to grant an application the specified permissions.
int removeBatteryOptimizationExemption(String packageName)
Call this method to remove the given application package from the device's power allowlist.
int revokePermissions(String packageName, ArrayList<String> permissions)
Call this method to revoke an application the specified permissions.
int setApplicationEnabledSetting(String packageName, int newState, int flags)
Call this method to set the enable setting for an application.
int setApplicationHidden(String packageName, boolean hidden)
Call this method to hide or unhide packages.
int setNotificationsEnabledForPackage(String packageName, boolean enabled)
Call this method to enable/disable the notifications of the given application.
int setStatusBarDisabled(boolean disabled)
Call this method to disable or enable the status bar.
int setUninstallBlocked(String packageName, boolean uninstallBlocked)
Change whether a user can uninstalling a package.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AppManager (Context context)

Added in revision 25

This is the constructor of AppManager.

Parameters
context Context The context of the calling app.
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

Public Methods

public int addBatteryOptimizationExemption (String packageName)

Added in revision 31

Call this method to place the given application package on the device's power allowlist.

Parameters
packageName String The name of the package to be added to the device's power allowlist.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int forceStopPackage (String packageName)

Added in revision 25

Call this method to stop an application.

Parameters
packageName String The package name of the application to be force stopped.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int grantAllPermissions (String packageName)

Added in revision 25

Call this method to grant an application all the permissions declared in its manifest.

The method works in best effort. If almost one of the requested permissions is not granted an error is returned. In case of error to check which permissions are granted use PackageManger.getPackageInfo(String packageName, int flags) with the flag PackageManager#GET_PERMISSIONS to get the PackageInfo of the application with the permissions information.

Parameters
packageName String The application to grant permissions to.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int grantPermissions (String packageName, ArrayList<String> permissions)

Added in revision 25

Call this method to grant an application the specified permissions.

The method works in best effort. If almost one of the requested permissions is not granted an error is returned. In case of error to check which permissions are granted use PackageManger.getPackageInfo(String packageName, int flags) with the flag PackageManager#GET_PERMISSIONS to get the PackageInfo of the application with the permissions information.

Parameters
packageName String The application to grant permissions to.
permissions ArrayList The list of permissions to be granted.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeBatteryOptimizationExemption (String packageName)

Added in revision 31

Call this method to remove the given application package from the device's power allowlist.

Parameters
packageName String The name of the package to be removed from the device's power allowlist.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int revokePermissions (String packageName, ArrayList<String> permissions)

Added in revision 28

Call this method to revoke an application the specified permissions.

The method works in best effort. If almost one of the requested permissions is not revoked an error is returned. In case of error to check which permissions are revoked use PackageManger.getPackageInfo(String packageName, int flags) with the flag PackageManager#GET_PERMISSIONS to get the PackageInfo of the application with the permissions information.

Parameters
packageName String The application to revoke permissions to.
permissions ArrayList The list of permissions to be revoked.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setApplicationEnabledSetting (String packageName, int newState, int flags)

Added in revision 25

Call this method to set the enable setting for an application.

Parameters
packageName String The package name of the application to enable.
newState int The new enabled state for the application.
flags int Optional behaviour flags. Value is either 0 or a combination of android.content.pm.PackageManager#DONT_KILL_APP and android.content.pm.PackageManager#SYNCHRONOUS. Not expected values in combinationation with these are ignored. See for more details the Android documentation PackageManager.setApplicationEnabledSetting(String packageName, int newState, int flags).
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setApplicationHidden (String packageName, boolean hidden)

Added in revision 25

Call this method to hide or unhide packages.

If the package is already hide/unhide the method returns GENERIC_ERROR.

Parameters
packageName String The name of the package to hide or unhide.
hidden boolean True if the package should be hidden, false if it should be unhidden.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setNotificationsEnabledForPackage (String packageName, boolean enabled)

Added in revision 34

Call this method to enable/disable the notifications of the given application.

Parameters
packageName StringThe package of the application for which to enable/disable notifications.
enabled booleanTrue to enable notifications, false to disable.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setStatusBarDisabled (boolean disabled)

Added in revision 31

Call this method to disable or enable the status bar.
Disabling the status bar blocks notifications and quick settings.

Parameters
disabled boolean True disables the status bar, false reenables it.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setUninstallBlocked (String packageName, boolean uninstallBlocked)

Added in revision 25

Change whether a user can uninstalling a package.

Parameters
packageName String The name of the package to change.
uninstallBlocked boolean True if the user shouldn't be able to uninstall the package.
Returns
Throws
AppManagerException in case of error, when exceptions are enabled through the ErrorManager singleton.