When will the app_terminate be called?

When will the app_terminate be called?

BY 21 Sep 2015 Native Application Development

I tried to add some release codes in the function app_terminate(). In the debugging, I tried many method to see if it is called, but never see the calling happens.

The codes for app_terminate is from the Tizen sample native application.

static void app_terminate(void *data) {
    /* Release all resources. */
 sensor_stop((appdata_s *)data);
    dlog_print(DLOG_ERROR, "glviewcubesample", "sensor_stop called!");
}

int main(int argc, char *argv[]) {
 appdata_s ad = { NULL, };
 int ret = 0;

 ui_app_lifecycle_callback_s event_callback = {NULL,};

 ad.name = "glviewcubesample";

 event_callback.create = app_create;
 event_callback.terminate = app_terminate;
 event_callback.pause = app_pause;
 event_callback.resume = app_resume;
 event_callback.app_control = app_control;

 ret = ui_app_main(argc, argv, &event_callback, &ad);
 if (ret != APP_ERROR_NONE) {
  dlog_print(DLOG_ERROR, LOG_TAG, "sample:The application failed to start, and returned %d", ret);
 }

 return ret;
}

Firstly, it’s apparently the function app_terminate() will not be called when I press back key, cause the callback for back key press is as below.

static void win_back_cb(void *data, Evas_Object *obj, void *event_info) {
    appdata_s *ad = data;

 /* Let window go to hidden state. */
 elm_win_lower(ad->win);
}

Secondly, I’m sure it will be called when the app is destroyed. Because win_delete_request_cb() called ui_app_exit();

static void win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
{
    ui_app_exit();
}

I tried to replace elm_win_lower() in win_back_cb() to ui_app_exit(), then app_terminate() is called.

But if I do not change the codes of win_back_cb(), the app_terminate() should can be called by system sometime.

Then I tried kill the app by long press the home key and click “clear all” to see if the app_terminate() is called. Nothing happens , no log show it been called.

I guess the Tizen system will take over to destroy the app after I click clear all, but when will the destory really happens?

I try to open many other applications to increase the memory usage to see if the system will destroy my app and called app_terminate(), but still not see the log.

 

 

Written by