@ohos.app.ability.appManager (appManager)

The appManager module implements application management. You can use the APIs of this module to query whether the application is undergoing a stability test, whether the application is running on a RAM constrained device, the memory size of the application, and information about the running process.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import appManager from '@ohos.app.ability.appManager';

appManager.isRunningInStabilityTest

static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void

Checks whether this application is undergoing a stability test. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Type Description
AsyncCallback<boolean> Callback used to return the API call result and the result true or false. You can perform error handling or custom processing in this callback. The value true means that the application is undergoing a stability test, and false means the opposite.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.isRunningInStabilityTest((err, flag) => {
    if (err.code !== 0) {
        console.log('isRunningInStabilityTest faile, err: ' + JSON.stringify(err));
    } else {
        console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
    }
});

appManager.isRunningInStabilityTest

static isRunningInStabilityTest(): Promise<boolean>

Checks whether this application is undergoing a stability test. This API uses a promise to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Return value

Type Description
Promise<boolean> Promise used to return the API call result and the result true or false. You can perform error handling or custom processing in this callback. The value true means that the application is undergoing a stability test, and false means the opposite.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.isRunningInStabilityTest().then((flag) => {
    console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
}).catch((error) => {
    console.log('error:' + JSON.stringify(error));
});

appManager.isRamConstrainedDevice

isRamConstrainedDevice(): Promise<boolean>;

Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Return value

Type Description
Promise<boolean> Promise used to return the API call result and the result true or false. You can perform error handling or custom processing in this callback. The value true means that the application is running on a RAM constrained device, and false means the opposite.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.isRamConstrainedDevice().then((data) => {
    console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
}).catch((error) => {
    console.log('error:' + JSON.stringify(error));
});

appManager.isRamConstrainedDevice

isRamConstrainedDevice(callback: AsyncCallback<boolean>): void;

Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Type Description
AsyncCallback<boolean> Callback used to return the API call result and the result true or false. You can perform error handling or custom processing in this callback. The value true means that the application is running on a RAM constrained device, and false means the opposite.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.isRamConstrainedDevice((err, data) => {
    if (err.code !== 0) {
        console.log('isRamConstrainedDevice faile, err: ' + JSON.stringify(err));
    } else {
        console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
    }
});

appManager.getAppMemorySize

getAppMemorySize(): Promise<number>;

Obtains the memory size of this application. This API uses a promise to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Return value

Type Description
Promise<number> Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.getAppMemorySize().then((data) => {
    console.log('The size of app memory is:' + JSON.stringify(data));
}).catch((error) => {
    console.log('error:' + JSON.stringify(error));
});

appManager.getAppMemorySize

getAppMemorySize(callback: AsyncCallback<number>): void;

Obtains the memory size of this application. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Type Description
AsyncCallback<number> Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.getAppMemorySize((err, data) => {
    if (err.code !== 0) {
        console.log('getAppMemorySize faile, err: ' + JSON.stringify(err));
    } else {
        console.log('The size of app memory is:' + JSON.stringify(data));
    }
});

appManager.getRunningProcessInformation

getRunningProcessInformation(): Promise<Array<ProcessInformation>>;

Obtains information about the running processes. This API uses a promise to return the result.

Required permissions: ohos.permission.GET_RUNNING_INFO

System capability: SystemCapability.Ability.AbilityRuntime.Core

Return value

Type Description
Promise<Array<ProcessInformation>> Promise used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.getRunningProcessInformation().then((data) => {
    console.log('The running process information is:' + JSON.stringify(data));
}).catch((error) => {
    console.log('error:' + JSON.stringify(error));
});

appManager.getRunningProcessInformation9+

getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void;

Obtains information about the running processes. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.GET_RUNNING_INFO

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Type Description
AsyncCallback<Array<ProcessInformation>> Callback used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.getRunningProcessInformation((err, data) => {
    if (err.code !== 0) {
        console.log('getRunningProcessInformation faile, err: ' + JSON.stringify(err));
    } else {
        console.log('The process running information is:' + JSON.stringify(data));
    }
});

appManager.on

on(type: 'applicationState', observer: ApplicationStateObserver): number;

Registers an observer to listen for the state changes of all applications.

Required permissions: ohos.permission.RUNNING_STATE_OBSERVER

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
type string Yes Type of the API to call. It is fixed at 'applicationState'.
observer ApplicationStateObserver Yes Application state observer, which is used to observe the lifecycle change of an application.

Return value

Type Description
number Digital code of the observer, which will be used in off() to deregister the observer.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let applicationStateObserver = {
    onForegroundApplicationChanged(appStateData) {
        console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
    },
    onAbilityStateChanged(abilityStateData) {
        console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
    },
    onProcessCreated(processData) {
        console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
    },
    onProcessDied(processData) {
        console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
    },
    onProcessStateChanged(processData) {
        console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
    }
};
try {
    const observerId = appManager.on('applicationState', applicationStateObserver);
    console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
    console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
}

appManager.on

on(type: 'applicationState', observer: ApplicationStateObserver, bundleNameList: Array<string>): number;

Registers an observer to listen for the state changes of a specified application.

Required permissions: ohos.permission.RUNNING_STATE_OBSERVER

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
type string Yes Type of the API to call. It is fixed at 'applicationState'.
observer ApplicationStateObserver Yes Application state observer, which is used to observe the lifecycle change of an application.
bundleNameList Array<string> Yes bundleName array of the application. A maximum of 128 bundle names can be passed.

Return value

Type Description
number Digital code of the observer, which will be used in off() to deregister the observer.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let applicationStateObserver = {
    onForegroundApplicationChanged(appStateData) {
        console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
    },
    onAbilityStateChanged(abilityStateData) {
        console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
    },
    onProcessCreated(processData) {
        console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
    },
    onProcessDied(processData) {
        console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
    },
    onProcessStateChanged(processData) {
        console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
    }
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
    const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
    console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
    console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
}

appManager.off

off(type: 'applicationState', observerId: number, callback: AsyncCallback<void>): void;

Deregisters the application state observer. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.RUNNING_STATE_OBSERVER

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
type string Yes Type of the API to call. It is fixed at 'applicationState'.
observerId number Yes Digital code of the observer.
callback AsyncCallback<void> Yes Callback used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let observerId = 0;

// 1. Register an application state observer.
let applicationStateObserver = {
    onForegroundApplicationChanged(appStateData) {
        console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
    },
    onAbilityStateChanged(abilityStateData) {
        console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
    },
    onProcessCreated(processData) {
        console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
    },
    onProcessDied(processData) {
        console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
    },
    onProcessStateChanged(processData) {
        console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
    }
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
    observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
    console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
    console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
}

// 2. Deregister the application state observer.
function unregisterApplicationStateObserverCallback(err) {
    if (err.code !== 0) {
        console.log('unregisterApplicationStateObserverCallback faile, err: ' + JSON.stringify(err));
    } else {
        console.log('unregisterApplicationStateObserverCallback success.');
    }
}
try {
    appManager.off('applicationState', observerId, unregisterApplicationStateObserverCallback);
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.off

off(type: 'applicationState', observerId: number): Promise<void>;

Deregisters the application state observer. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.RUNNING_STATE_OBSERVER

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
type string Yes Type of the API to call. It is fixed at 'applicationState'.
observerId number Yes Digital code of the observer.

Return value

Type Description
Promise<void> Promise used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let observerId = 0;

// 1. Register an application state observer.
let applicationStateObserver = {
    onForegroundApplicationChanged(appStateData) {
        console.log(`[appManager] onForegroundApplicationChanged: ${JSON.stringify(appStateData)}`);
    },
    onAbilityStateChanged(abilityStateData) {
        console.log(`[appManager] onAbilityStateChanged: ${JSON.stringify(abilityStateData)}`);
    },
    onProcessCreated(processData) {
        console.log(`[appManager] onProcessCreated: ${JSON.stringify(processData)}`);
    },
    onProcessDied(processData) {
        console.log(`[appManager] onProcessDied: ${JSON.stringify(processData)}`);
    },
    onProcessStateChanged(processData) {
        console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
    }
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
    observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
    console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
    console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
}
    
// 2. Deregister the application state observer.
try {
    appManager.off('applicationState', observerId).then((data) => {
        console.log('unregisterApplicationStateObserver success, data: ' + JSON.stringify(data));
    }).catch((err) => {
        console.log('unregisterApplicationStateObserver faile, err: ' + JSON.stringify(err));
    });
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.getForegroundApplications

getForegroundApplications(callback: AsyncCallback<Array<AppStateData>>): void;

Obtains applications that are running in the foreground. This API uses an asynchronous callback to return the result. The application information is defined by AppStateData.

Required permissions: ohos.permission.GET_RUNNING_INFO

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Parameters

Name Type Mandatory Description
callback AsyncCallback<Array<AppStateData>> Yes Callback used to return the API call result and an array holding the application state data. You can perform error handling or custom processing in this callback.

Example

import appManager from '@ohos.app.ability.appManager';

function getForegroundApplicationsCallback(err, data) {
    if (err.code !== 0) {
        console.log('getForegroundApplicationsCallback fail, err: ' + JSON.stringify(err));
    } else {
        console.log('getForegroundApplicationsCallback success, data: ' + JSON.stringify(data));
    }
}
try {
    appManager.getForegroundApplications(getForegroundApplicationsCallback);
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.getForegroundApplications

getForegroundApplications(): Promise<Array<AppStateData>>;

Obtains applications that are running in the foreground. This API uses a promise to return the result. The application information is defined by AppStateData.

Required permissions: ohos.permission.GET_RUNNING_INFO

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Return value

Type Description
Promise<Array<AppStateData>> Promise used to return an array holding the application state data

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

appManager.getForegroundApplications().then((data) => {
    console.log('getForegroundApplications success, data: ' + JSON.stringify(data));
}).catch((err) => {
    console.log('getForegroundApplications fail, err: ' + JSON.stringify(err));
});

appManager.killProcessWithAccount

killProcessWithAccount(bundleName: string, accountId: number): Promise<void>

Kills a process by bundle name and account ID. This API uses a promise to return the result.

Required permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.
accountId number Yes ID of a system account. For details, see getCreatedOsAccountsCount.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
let accountId = 0;
try {
    appManager.killProcessWithAccount(bundleName, accountId).then(() => {
        console.log('killProcessWithAccount success');
    }).catch((err) => {
        console.error('killProcessWithAccount fail, err: ' + JSON.stringify(err));
    });
} catch (paramError) {
    console.error('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.killProcessWithAccount

killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback<void>): void

Kills a process by bundle name and account ID. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Required permissions: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.
accountId number Yes ID of a system account. For details, see getCreatedOsAccountsCount.
callback AsyncCallback<void> Yes Callback used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
let accountId = 0;
function killProcessWithAccountCallback(err, data) {
    if (err.code !== 0) {
        console.log('killProcessWithAccountCallback fail, err: ' + JSON.stringify(err));
    } else {
        console.log('killProcessWithAccountCallback success.');
    }
}
appManager.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback);

appManager.killProcessesByBundleName

killProcessesByBundleName(bundleName: string, callback: AsyncCallback<void>);

Kills a process by bundle name. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.CLEAN_BACKGROUND_PROCESSES

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.
callback AsyncCallback<void> Yes Callback used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) {
    if (err.code !== 0) {
        console.log('killProcessesByBundleNameCallback fail, err: ' + JSON.stringify(err));
    } else {
        console.log('killProcessesByBundleNameCallback success.');
    }
}
try {
    appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.killProcessesByBundleName

killProcessesByBundleName(bundleName: string): Promise<void>;

Kills a process by bundle name. This API uses a promise to return the result.

Required permissions: ohos.permission.CLEAN_BACKGROUND_PROCESSES

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
try {
    appManager.killProcessesByBundleName(bundleName).then((data) => {
        console.log('killProcessesByBundleName success.');
    }).catch((err) => {
        console.log('killProcessesByBundleName fail, err: ' + JSON.stringify(err));
    });
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.clearUpApplicationData

clearUpApplicationData(bundleName: string, callback: AsyncCallback<void>);

Clears application data by bundle name. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.CLEAN_APPLICATION_DATA

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.
callback AsyncCallback<void> Yes Callback used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) {
    if (err) {
        console.log('clearUpApplicationDataCallback fail, err: ' + JSON.stringify(err));
    } else {
        console.log('clearUpApplicationDataCallback success.');
    }
}
try {
    appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

appManager.clearUpApplicationData

clearUpApplicationData(bundleName: string): Promise<void>;

Clears application data by bundle name. This API uses a promise to return the result.

Required permissions: ohos.permission.CLEAN_APPLICATION_DATA

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name.

Return value

Type Description
Promise<void> Promise used to return the API call result. You can perform error handling or custom processing in this callback.

Error codes

ID Error Message
16000050 Internal error.

For details about the error codes, see Ability Error Codes.

Example

import appManager from '@ohos.app.ability.appManager';

let bundleName = 'bundleName';
try {
    appManager.clearUpApplicationData(bundleName).then((data) => {
        console.log('clearUpApplicationData success.');
    }).catch((err) => {
        console.log('clearUpApplicationData fail, err: ' + JSON.stringify(err));
    });
} catch (paramError) {
    console.log('error: ' + paramError.code + ', ' + paramError.message);
}

ApplicationState

Enumerates the application states. This enum can be used together with AbilityStateData to return the application state.

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Name Value Description
STATE_CREATE 1 State indicating that the application is being created.
STATE_FOREGROUND 2 State indicating that the application is running in the foreground.
STATE_ACTIVE 3 State indicating that the application is active.
STATE_BACKGROUND 4 State indicating that the application is running in the background.
STATE_DESTROY 5 State indicating that the application is destroyed.

ProcessState

Enumerates the process states. This enum can be used together with ProcessData to return the process state.

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API and cannot be called by third-party applications.

Name Value Description
STATE_CREATE 1 State indicating that the process is being created.
STATE_FOREGROUND 2 State indicating that the process is running in the foreground.
STATE_ACTIVE 3 State indicating that the process is active.
STATE_BACKGROUND 4 State indicating that the process is running in the background.
STATE_DESTROY 5 State indicating that the process is destroyed.