java.lang.Object | |
↳ | com.datalogic.device.app.AppManager |
AppManager
gives developers the ability to manage installed applications.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This is the constructor of AppManager.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Call this method to place the given application package on the device's power allowlist.
| |||||||||||
Call this method to enable/disable the specified list of NotificationChannels of a given application.
| |||||||||||
Call this method to stop an application.
| |||||||||||
Call this method to get the list of NotificationChannel defined by a given application.
| |||||||||||
Call this method to grant an application all the runtime permissions declared in its manifest.
| |||||||||||
Call this method to grant an application the specified runtime permissions.
| |||||||||||
Call this method to remove the given application package from the device's power allowlist.
| |||||||||||
Call this method to revoke an application the specified runtime permissions.
| |||||||||||
Call this method to set the enable setting for an application.
| |||||||||||
Call this method to hide or unhide packages.
| |||||||||||
Call this method to set the mode of the specified app-ops permissions of a given application.
| |||||||||||
Call this method to enable/disable the notifications of the given application.
| |||||||||||
Call this method to disable or enable the status bar.
| |||||||||||
Change whether a user can uninstalling a package.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This is the constructor of AppManager.
context | Context
The context of the calling app. |
---|
AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to place the given application package on the device's power allowlist.
packageName | String The name of the package to be added to the device's power allowlist. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to enable/disable the specified list of NotificationChannels of a given application.
The NotificationChannels are specified using their identifier.
To enable/disable all the NotificationChannels of an app use as value of the parameter notificationChannels the regular expression "^(?:[\\w| ]*)$".
To disable all the NotificationChannels of the Clock app:
AppManager appmanager = new AppManager(this); int result = appManager.enableNotificationChannels("com.google.android.deskclock", "^(?:[\\w| ]*)$", false);To disable the NotificationChannels Bedtime, Timers, Firing alarms & timers, Missed alarms of the Clock app:
AppManager appmanager = new AppManager(this); int result = appManager.enableNotificationChannels("com.google.android.deskclock", "^(?:Bedtime|Timers|Firing|Missed Alarms)$", false);The identifier of the NotificationChannels are obtained getting the list of all the NotificationChannels of the app and looking, in the returned list, for their identifier.
AppManager appmanager = new AppManager(this); Listchannels = new ArrayList (); int result = appmanager.getNotificationChannels("com.google.android.deskclock", channels); for (NotificationChannel channel : channels) { Log.d(TAG, "channel=" + channel.getId()); }
packageName | String The package name of the application whose NotificationChannels are to be enabled/disabled. |
---|---|
notificationChannels | String Regular expression that lists the identifiers of the NotificationChannels to be enabled/disabled. |
enabled | boolean False to disable the notification channels, true to enable the notification channels with the
importance defined when the channel was created. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to stop an application.
packageName | String The package name of the application to be force stopped. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to get the list of NotificationChannel defined by a given application.
This method is usefull to know the NotificationChannel identifier to be used in enableNotificationChannels(String, String, boolean)
.
NotificationChannel name is the name, localized, used as label to show the NotificationChannel on the Android Settings..
packageName | String The package name of the application whose NotificationChannel is given back. |
---|---|
notificationChannels | List<NotificationChannel> Call the method passing an empty list. In output the list will contains the NotificationChannels defined by the given app. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to grant an application all the runtime permissions declared in its manifest.
If the application is a system application the method fails and returns the exception SECURITY_ERROR
or the corresponding error.
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.
packageName | String The application to grant permissions to. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to grant an application the specified runtime permissions.
If the application is a system application the method fails and returns the exception SECURITY_ERROR
or the corresponding error.
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.
packageName | String The application to grant permissions to. |
---|---|
permissions | ArrayList The list of permissions to be granted. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to remove the given application package from the device's power allowlist.
packageName | String The name of the package to be removed from the device's power allowlist. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to revoke an application the specified runtime permissions.
If the application is a system application the method fails and returns the exception SECURITY_ERROR
or the corresponding error.
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.
packageName | String The application to revoke permissions to. |
---|---|
permissions | ArrayList The list of permissions to be revoked. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to set the enable setting for an application.
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). |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to hide or unhide packages.
If the package is already hide/unhide the method returns GENERIC_ERROR
.
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. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to set the mode of the specified app-ops permissions of a given application.
If the application is a system application the method fails and returns the exception SECURITY_ERROR
or the corresponding error.
packageName | String The application to grant permissions to. If the application is a system application the method fails. |
---|---|
permissions | ArrayList The list of app-ops permissions to be set. |
mode | int AppOpsManager.MODE_ALLOWED: the given application is allowed to perform the given operation. AppOpsManager.MODE_IGNORED: the given application not allowed to perform the given operation, and the attempt should silently fail (it should not cause the app to crash). AppOpsManager.MODE_ERRORED: the given application not allowed to perform the given operation, and the attempt should cause it to have a fatal error. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to enable/disable the notifications of the given application.
packageName | String The package of the application for which to enable/disable notifications. |
---|---|
enabled | boolean True to enable notifications, false to disable. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Call this method to disable or enable the status bar.
Disabling the status bar blocks notifications and quick settings.
disabled | boolean True disables the status bar, false reenables it. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Change whether a user can uninstalling a package.
packageName | String The name of the package to change. |
---|---|
uninstallBlocked | boolean True if the user shouldn't be able to uninstall the package. |
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the AppManagerException
error constants.AppManagerException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|