Tizen Native API  7.0

Launches or exits serviceApp.

Required Header

#include <service_app.h>

Overview

The Service Application API provides functions for handling Tizen service application state changes or system events. This API provides interfaces for the following three categories:

  • Starting or exiting the main event loop.
  • Registering callbacks for application state change events.
  • Registering callbacks for basic system events.

Functions

int service_app_add_event_handler (app_event_handler_h *handler, app_event_type_e event_type, app_event_cb callback, void *user_data)
 Adds the system event handler.
int service_app_remove_event_handler (app_event_handler_h event_handler)
 Removes registered event handler.
int service_app_main (int argc, char **argv, service_app_lifecycle_callback_s *callback, void *user_data)
 Runs the main loop of the application until service_app_exit() is called.
void service_app_exit (void)
 Exits the main loop of the application.

Typedefs

typedef bool(* service_app_create_cb )(void *user_data)
 Called at the start of the agent application.
typedef void(* service_app_terminate_cb )(void *user_data)
 Called once after the main loop of the agent application exits.
typedef void(* service_app_control_cb )(app_control_h app_control, void *user_data)
 Called when another application sends the launch request to the agent application.

Typedef Documentation

typedef void(* service_app_control_cb)(app_control_h app_control, void *user_data)

Called when another application sends the launch request to the agent application.

Since :
2.3
Parameters:
[in]app_controlThe handle to the app_control
[in]user_dataThe user data passed from the callback registration function
See also:
service_app_main()
service_app_lifecycle_callback_s
App Control API
typedef bool(* service_app_create_cb)(void *user_data)

Called at the start of the agent application.

Since :
2.3
Parameters:
[in]user_dataThe user data passed from the callback registration function
Returns:
true on success, otherwise false
Precondition:
service_app_main() will invoke this callback function.
See also:
service_app_main()
service_app_lifecycle_callback_s
typedef void(* service_app_terminate_cb)(void *user_data)

Called once after the main loop of the agent application exits.

Since :
2.3
Parameters:
[in]user_dataThe user data passed from the callback registration function
See also:
service_app_main()
service_app_lifecycle_callback_s

Function Documentation

int service_app_add_event_handler ( app_event_handler_h handler,
app_event_type_e  event_type,
app_event_cb  callback,
void *  user_data 
)

Adds the system event handler.

Since :
2.3
Remarks:
The service application can handle low memory event, low battery event, language setting changed event and region format changed event.
Parameters:
[out]handlerThe event handler
[in]event_typeThe system event type
[in]callbackThe callback function
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
APP_ERROR_NONESuccessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
APP_ERROR_OUT_OF_MEMORYOut of memory
See also:
app_event_type_e
app_event_cb()
service_app_remove_event_handler()
void service_app_exit ( void  )

Exits the main loop of the application.

The main loop of the application stops and service_app_terminate_cb() is invoked.

Since :
2.3
See also:
service_app_main()
service_app_terminate_cb()
int service_app_main ( int  argc,
char **  argv,
service_app_lifecycle_callback_s callback,
void *  user_data 
)

Runs the main loop of the application until service_app_exit() is called.

This function is the main entry point of the Tizen service application. This main loop supports event handling for the GMainLoop and the Ecore Main Loop.

Since :
2.3
Parameters:
[in]argcThe argument count
[in]argvThe argument vector
[in]callbackThe set of callback functions to handle application events
[in]user_dataThe user data to be passed to the callback functions
Returns:
0 on success, otherwise a negative error value.
Return values:
APP_ERROR_NONESuccessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
APP_ERROR_INVALID_CONTEXTThe application is launched illegally, not launched by the launch system.
APP_ERROR_ALREADY_RUNNINGThe main loop has already started
See also:
service_app_create_cb()
service_app_terminate_cb()
service_app_control_cb()
service_app_exit()
service_app_lifecycle_callback_s

Removes registered event handler.

Since :
2.3
Parameters:
[in]event_handlerThe event handler
Returns:
0 on success, otherwise a negative error value
Return values:
APP_ERROR_NONESuccessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
See also:
service_app_add_event_handler()