Tizen Native API
Application Context

The Application Context API contains functions for obtaining information about running applications.

Required Header

#include <app_manager.h>

Overview

Remarks:
The Application Context API provides information about running applications.

Functions

int app_context_destroy (app_context_h app_context)
 Destroys the application context handle and releases all its resources.
int app_context_get_package (app_context_h app_context, char **package) TIZEN_DEPRECATED_API
 Gets the application ID with the given application context.
int app_context_get_app_id (app_context_h app_context, char **app_id)
 Gets the application ID with the given application context.
int app_context_get_pid (app_context_h app_context, pid_t *pid)
 Gets the process ID with the given application context.
int app_context_get_package_id (app_context_h app_context, char **pkg_id)
 Gets the package id with the given application context.
int app_context_get_app_state (app_context_h app_context, app_state_e *state)
 Gets the application state with the given application context.
int app_context_is_terminated (app_context_h app_context, bool *terminated)
 Checks whether the application with the given application context is terminated.
int app_context_is_equal (app_context_h lhs, app_context_h rhs, bool *equal)
 Checks whether two application contexts are equal.
int app_context_is_sub_app (app_context_h app_context, bool *is_sub_app)
 Checks whether the application is running as a sub application of the application group.
int app_context_clone (app_context_h *clone, app_context_h app_context)
 Clones the application context handle.

Typedefs

typedef struct app_context_s * app_context_h
 Application context handle.

Typedef Documentation

typedef struct app_context_s* app_context_h

Application context handle.

Since :
2.3

Enumeration Type Documentation

Enumeration for Application Context Event.

Since :
2.4
Enumerator:
APP_CONTEXT_EVENT_LAUNCHED 

The application is launched

APP_CONTEXT_EVENT_TERMINATED 

The application is terminated

Enumeration for the application state.

Since :
3.0
Enumerator:
APP_STATE_UNDEFINED 

The undefined state

APP_STATE_FOREGROUND 

The UI application is running in the foreground.

APP_STATE_BACKGROUND 

The UI application is running in the background.

APP_STATE_SERVICE 

The Service application is running.

APP_STATE_TERMINATED 

The application is terminated.


Function Documentation

int app_context_clone ( app_context_h clone,
app_context_h  app_context 
)

Clones the application context handle.

Since :
2.3
Parameters:
[out]cloneThe newly created application context handle, if cloning is successful
[in]app_contextThe application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
APP_MANAGER_ERROR_OUT_OF_MEMORYOut of memory
int app_context_destroy ( app_context_h  app_context)

Destroys the application context handle and releases all its resources.

Since :
2.3
Parameters:
[in]app_contextThe application context handle
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
app_manager_foreach_app_context()
app_manager_get_app_context()
int app_context_get_app_id ( app_context_h  app_context,
char **  app_id 
)

Gets the application ID with the given application context.

Since :
2.3
Remarks:
You must release app_id using free().
Parameters:
[in]app_contextThe application context
[out]app_idThe application ID of the given application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
APP_MANAGER_ERROR_OUT_OF_MEMORYOut of memory
int app_context_get_app_state ( app_context_h  app_context,
app_state_e state 
)

Gets the application state with the given application context.

Since :
3.0
Remarks:
Note that application's state might be changed after you get app_context. This API just returns the state of application when you get the app_context.
Parameters:
[in]app_contextThe application context
[out]stateThe application state of the given application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
int app_context_get_package ( app_context_h  app_context,
char **  package 
)

Gets the application ID with the given application context.

Deprecated:
Deprecated since 2.3.1. Use app_context_get_app_id() instead.
Since :
2.3
Remarks:
You must release package using free().
Parameters:
[in]app_contextThe application context
[out]packageThe application ID of the given application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
APP_MANAGER_ERROR_OUT_OF_MEMORYOut of memory
int app_context_get_package_id ( app_context_h  app_context,
char **  pkg_id 
)

Gets the package id with the given application context.

Since :
3.0
Remarks:
You must release pkg_id using free().
Parameters:
[in]app_contextThe application context
[out]pkg_idThe package ID of the given application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
APP_MANAGER_ERROR_OUT_OF_MEMORYOut of memory
int app_context_get_pid ( app_context_h  app_context,
pid_t *  pid 
)

Gets the process ID with the given application context.

Since :
2.3
Parameters:
[in]app_contextThe application context
[out]pidThe process ID of the given application context
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
int app_context_is_equal ( app_context_h  lhs,
app_context_h  rhs,
bool *  equal 
)

Checks whether two application contexts are equal.

Since :
2.3
Parameters:
[in]lhsThe first application context to compare
[in]rhsThe second application context to compare
[out]equaltrue if the application contexts are equal,
otherwise false if they are not equal
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
int app_context_is_sub_app ( app_context_h  app_context,
bool *  is_sub_app 
)

Checks whether the application is running as a sub application of the application group.

Since :
3.0
Parameters:
[in]app_contextThe application context
[out]is_sub_apptrue if the sub application of the group,
otherwise false if the main application of the group
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter
int app_context_is_terminated ( app_context_h  app_context,
bool *  terminated 
)

Checks whether the application with the given application context is terminated.

Since :
2.3
Parameters:
[in]app_contextThe application context
[out]terminatedtrue if the application is terminated,
otherwise false if the application is running
Returns:
0 on success, otherwise a negative error value
Return values:
APP_MANAGER_ERROR_NONESuccessful
APP_MANAGER_ERROR_INVALID_PARAMETERInvalid parameter