How to get the most recently used applications list
Way to get the recently used app list.
#include <context_history.h>
void
get_recently_used_apps()
{
context_history_h history_h = NULL;
context_history_list_h list_h = NULL;
context_history_record_h record_h = NULL;
context_history_filter_h filter_h = NULL;
int history_count = -1;
char* app_id = NULL;
/* create history handle */
context_history_create(&history_h);
/* create filter handle */
context_history_filter_create(&filter_h);
/* get history list */
context_history_get_list(history_h, CONTEXT_HISTORY_RECENTLY_USED_APP, filter_h, &list_h);
/* get history list count */
context_history_list_get_count(list_h, &history_count);;
char text_buf[1000] = {'\0'};
/* extract records from list */
for (int i = 0; i < history_count; i++) {
/* get a record from list */
context_history_list_get_current(list_h, &record_h);
/* get attribute : App Id */
context_history_record_get_string(record_h, CONTEXT_HISTORY_APP_ID, &app_id);
/* move to next record */
context_history_list_move_next(list_h);
strcat(text_buf, app_id);
strcat(text_buf, "\n");
}
dlog_print(DLOG_DEBUG, "result", text_buf);
}