Added in API level 1
public interface

IAppGeneralManager

com.ardic.android.managers.appgeneral.IAppGeneralManager

Class Overview

Provides a set of APIs to manage application related information and operations.

Summary

Constants
int DISPLAY_ORDER_APP_NAME In app name alphabetical order
int DISPLAY_ORDER_LAUNCH_COUNT In launch count decreasing order
int DISPLAY_ORDER_USAGE_TIME In usage time decreasing order
int REMOVE_TASK_KILL_PROCESS
Public Methods
abstract boolean addAppShortcut(String packageName, String className)
Adds the given application shortcut to the default workspace.
abstract boolean clearAppCache(String packageName)
Clears the given application cache.
abstract boolean clearAppData(String packageName)
Clears the given application data.
abstract boolean clearAppDefaults(String packageName)
Clears the given application all preferred assignments to launch by default application.
abstract boolean clearRecentTasks(int getFlags, int removeFlags)
Clears all tasks that the user has recently launched from task history.
abstract String getAppName(String packageName)
Returns application name of the given application.
abstract List<String> getAppShortcutList()
Returns the all application shortcut from the all workspace.
abstract int getAppUid(String packageName)
Returns user id of the given application.
abstract List<UsageStatsItem> getAppUsageStats(int displayOrder)
This method was deprecated in API level 5. in Android Lollipop
abstract int getAppVersionCode(String packageName)
Returns version code of the given application.
abstract String getAppVersionName(String packageName)
Returns version name of the given application.
abstract String getPackagePublicCertificate(String packageName)
Returns package's public certificate.
abstract PackageStatsItem getPackageStats(String packageName)
Returns PackageStatsItem of the given application.
abstract ProcessStatsItem getProcessStats(String packageName)
Returns process stats of the given application.
abstract List<String> getRecentTasks(int maxNum, int getFlags)
This method was deprecated in API level 5. in Android Lollipop
abstract boolean isAppRunning(String packageName)
Checks if the given application is running or not.
abstract boolean isAppUsageAccessEnabled()
Gets caller application's "Usage of Apps" access state.
abstract boolean isAppUsageAccessLocked()
Gets caller application's "Usage of Apps" access locking state.The access can not be deactivated by any application or user instead of itself.
abstract void moveTaskToFront(int taskId, int flags)
Ask that the task associated with a given task ID be moved to the front of the stack, so it is now visible to the user.
abstract boolean removeAppShortcut(String packageName, String className)
Removes the given application shortcut from the default workspace.
abstract boolean removeRecentTask(String packageName, int getFlags, int removeFlags)
Removes the given task that the user has recently launched from task history.
abstract boolean setAppUsageAccessEnabled(boolean state)
Sets caller application's "Usage of Apps" access state.
abstract boolean setAppUsageAccessLocked(boolean state)
Sets caller application's "Usage of Apps" access locking state if it is enabled.
abstract boolean setPackageStoppedState(String packageName, boolean state)
Sets the given application stopped state, mostly for the ability to receive broadcast messages.
abstract boolean startApp(String packageName)
Starts the given application if it includes MAIN activity.
abstract boolean stopApp(String packageName)
Stops the given application if it has already started.

Constants

public static final int DISPLAY_ORDER_APP_NAME

Added in API level 1

In app name alphabetical order

Constant Value: 2 (0x00000002)

public static final int DISPLAY_ORDER_LAUNCH_COUNT

Added in API level 1

In launch count decreasing order

Constant Value: 1 (0x00000001)

public static final int DISPLAY_ORDER_USAGE_TIME

Added in API level 1

In usage time decreasing order

Constant Value: 0 (0x00000000)

public static final int REMOVE_TASK_KILL_PROCESS

Added in API level 1

Constant Value: 1 (0x00000001)

Public Methods

public abstract boolean addAppShortcut (String packageName, String className)

Added in API level 1

Adds the given application shortcut to the default workspace. Warning: This api is asynchronous so returning true means this api called successfully. This doesn't mean shortcut will be added.

Parameters
packageName String: Application package name
className String: Application activity name
Returns
boolean true if the operation started successfully else false
Throws
AfexException

public abstract boolean clearAppCache (String packageName)

Added in API level 1

Clears the given application cache.

Parameters
packageName String: Application package name
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearAppData (String packageName)

Added in API level 1

Clears the given application data.

Parameters
packageName String: Application package name
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearAppDefaults (String packageName)

Added in API level 1

Clears the given application all preferred assignments to launch by default application.

Parameters
packageName String: Application package name
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract boolean clearRecentTasks (int getFlags, int removeFlags)

Added in API level 1

Clears all tasks that the user has recently launched from task history.

Parameters
getFlags int: Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and RECENT_IGNORE_UNAVAILABLE.
removeFlags int: Additional operational flags. May be 0 or REMOVE_TASK_KILL_PROCESS.
Returns
boolean true if the operation succeeds else false
Throws
AfexException

public abstract String getAppName (String packageName)

Added in API level 1

Returns application name of the given application.

Parameters
packageName String: Application package name
Returns
String application label if application exists else given package name
Throws
AfexException

public abstract List<String> getAppShortcutList ()

Added in API level 1

Returns the all application shortcut from the all workspace.

Returns
List<String> All shortcut's package name list
Throws
AfexException

public abstract int getAppUid (String packageName)

Added in API level 1

Returns user id of the given application.

Parameters
packageName String: Application package name
Returns
int Application user id
Throws
AfexException

public abstract List<UsageStatsItem> getAppUsageStats (int displayOrder)

Added in API level 1

This method was deprecated in API level 5.
in Android Lollipop

Returns UsageStatsItem list in the given display order. In Android Lollipop; After API level 21, This API throws ERROR(/AfexExceptionType.NA) After Lollipop, use UsageStatsManager

Parameters
displayOrder int: Orders displays as follows;
  • DISPLAY_ORDER_USAGE_TIME - In usage time decreasing order
  • DISPLAY_ORDER_LAUNCH_COUNT - In launch count decreasing order
  • DISPLAY_ORDER_APP_NAME - In app name alphabetical order
  • Others - In natural aggregating order
  • Returns
    List<UsageStatsItem> UsageStatsItem list which is ordered by displayOrder else null
    Throws
    AfexException

    public abstract int getAppVersionCode (String packageName)

    Added in API level 1

    Returns version code of the given application.

    Parameters
    packageName String: Application package name
    Returns
    int Application version code
    Throws
    AfexException

    public abstract String getAppVersionName (String packageName)

    Added in API level 1

    Returns version name of the given application.

    Parameters
    packageName String: Application package name
    Returns
    String Application version name
    Throws
    AfexException

    public abstract String getPackagePublicCertificate (String packageName)

    Added in API level 2

    Returns package's public certificate.

    Parameters
    packageName String: Target package name
    Returns
    String String if certificate is found else null
    Throws
    AfexException

    public abstract PackageStatsItem getPackageStats (String packageName)

    Added in API level 1

    Returns PackageStatsItem of the given application. PackageStatsItem can be obsolete if user clears package related part. So after each package related operations user could call this API to refresh package stats.

    Parameters
    packageName String: Application package name
    Returns
    PackageStatsItem PackageStatsItem or null if package does not exist
    Throws
    AfexException

    public abstract ProcessStatsItem getProcessStats (String packageName)

    Added in API level 1

    Returns process stats of the given application.

    Parameters
    packageName String: Application package name
    Returns
    ProcessStatsItem ProcessStatsItem
    Throws
    AfexException

    public abstract List<String> getRecentTasks (int maxNum, int getFlags)

    Added in API level 1

    This method was deprecated in API level 5.
    in Android Lollipop

    Returns a list of the tasks that the user has recently launched, with the most recent being first and older ones after in order.

    Note: this method is only intended for debugging and presenting task management user interfaces. This should never be used for core logic in an application, such as deciding between different behaviors based on the information found here. Such uses are not supported, and will likely break in the future. For example, if multiple applications can be actively running at the same time, assumptions made about the meaning of the data here for purposes of control flow will be incorrect.

    Parameters
    maxNum int: The maximum number of entries to return in the list. The actual number returned may be smaller, depending on how many tasks the user has started and the maximum number the system can remember.
    getFlags int: Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and RECENT_IGNORE_UNAVAILABLE.
    Returns
    List<String> List of RecentTaskInfo's package name records describing each of the recent tasks.
    Throws
    AfexException

    public abstract boolean isAppRunning (String packageName)

    Added in API level 1

    Checks if the given application is running or not.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if application is running else false
    Throws
    AfexException

    public abstract boolean isAppUsageAccessEnabled ()

    Added in API level 5

    Gets caller application's "Usage of Apps" access state. In Android Lollipop; After API level 21, This API throws ERROR(/AfexExceptionType.NA)

    Returns
    boolean true if it is enabled else false
    Throws
    AfexException

    public abstract boolean isAppUsageAccessLocked ()

    Added in API level 5

    Gets caller application's "Usage of Apps" access locking state.The access can not be deactivated by any application or user instead of itself. In Android Lollipop; After API level 21, This API throws ERROR(/AfexExceptionType.NA)

    Returns
    boolean true if it is locked else false
    Throws
    AfexException

    public abstract void moveTaskToFront (int taskId, int flags)

    Added in API level 1

    Ask that the task associated with a given task ID be moved to the front of the stack, so it is now visible to the user.

    Parameters
    taskId int: The identifier of the task to be moved, as found in RunningTaskInfo or RecentTaskInfo.
    flags int: Additional operational flags, 0 or more of MOVE_TASK_WITH_HOME and MOVE_TASK_NO_USER_ACTION.
    Throws
    AfexException

    public abstract boolean removeAppShortcut (String packageName, String className)

    Added in API level 1

    Removes the given application shortcut from the default workspace. Warning: This api is asynchronous so returning true means this api called successfully. This doesn't mean shortcut will be removed.

    Parameters
    packageName String: Application package name
    className String: Application activity name
    Returns
    boolean true if the operation started successfully else false
    Throws
    AfexException

    public abstract boolean removeRecentTask (String packageName, int getFlags, int removeFlags)

    Added in API level 1

    Removes the given task that the user has recently launched from task history.

    Parameters
    packageName String: Target removing task's package name.
    getFlags int: Information about what to return. May be any combination of RECENT_WITH_EXCLUDED and RECENT_IGNORE_UNAVAILABLE.
    removeFlags int: Additional operational flags. May be 0 or REMOVE_TASK_KILL_PROCESS.
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setAppUsageAccessEnabled (boolean state)

    Added in API level 5

    Sets caller application's "Usage of Apps" access state. In Android Lollipop; After API level 21, This API throws ERROR(/AfexExceptionType.NA)

    Parameters
    state boolean: true provides App Usage access to caller app access instead of itself, false not access.
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean setAppUsageAccessLocked (boolean state)

    Added in API level 5

    Sets caller application's "Usage of Apps" access locking state if it is enabled. In Android Lollipop; After API level 21, This API throws ERROR(/AfexExceptionType.NA) Firstly, you can enable the acces by ERROR(/setAppUsageAccessEnabled) The access can not be deactivated by any application or user instead of itself.

    Parameters
    state boolean: true locks App Usage access to caller app and nothing can remove it's access instead of itself, false unlocks.
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    See also:

    public abstract boolean setPackageStoppedState (String packageName, boolean state)

    Added in API level 1

    Sets the given application stopped state, mostly for the ability to receive broadcast messages. When a new application is installed, it's stop state is true until the user explicitly starts it. Only force stop sets stop state back to true again.

    Parameters
    packageName String: Application package name,
    state boolean: Application stop state. If state is false the application will exit stopped state. Therefore, the application can handle most of the prohibited broadcasts such as ACTION_BOOT_COMPLETED
    Returns
    boolean true if the operation succeeds else false
    Throws
    AfexException

    public abstract boolean startApp (String packageName)

    Added in API level 1

    Starts the given application if it includes MAIN activity.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if application has MAIN activity and start activity intent broadcasted successfully else false
    Throws
    AfexException

    public abstract boolean stopApp (String packageName)

    Added in API level 1

    Stops the given application if it has already started.

    Parameters
    packageName String: Application package name
    Returns
    boolean true if application force stopping called (the end result depends on application's killable attribute) else false
    Throws
    AfexException