Sticker Consumer Sample Overview

Mobile native

The Sticker Consumer sample application demonstrates how to use Sticker API to retrieve sticker data.

When the application shows the stickers, the data of the stickers must be stored in the sticker database.

The following figure illustrates the views of the Sticker Consumer:

Sticker Consumer views

To use the related Sticker functions, you can tap one of the available items from the list. To navigate backwards, you can use the back button.

Prerequisites

To ensure proper application execution, the following privilege must be set:

  • http://tizen.org/privilege/mediastorage
  • Implementation

    To implement the application:

    1. Create the layout for the application.

      This sample application uses native UI components (including a gengrid), and the appdata_s and itemdata_s structure to manage the UI component implementation. However, this page explains how to use the Sticker API and not the UI components. For more information on the usage of UI component, see the UI components sample application.

    2. Initialize sticker consumer.

      To use the Sticker Consumer library, you must initialize the sticker consumer using sticker_consumer_create(). When the Application starts, sticker_consumer_create() creates the sticker consumer handle.

      static bool
      app_create(void *data)
      {
         .....
      
         create_base_gui(ad);
      
         int ret = sticker_consumer_create(&g_ch);
         if (ret != STICKER_ERROR_NONE)
         {
            // Do something
         }
      
         return true;
      }
      

      When the Sticker feature is no longer needed, call sticker_consumer_destroy() to destroy the handle.

      static void
      app_terminate(void *data)
      {
         .....
      
         if (g_ch != NULL) {
            int ret = sticker_consumer_destroy(g_ch);
            if (ret != STICKER_ERROR_NONE)
            {
               // Do something
            }
         }
      }
      
    3. Retrieve the sticker data.

      The application shows all the stickers when Retrieves all sticker data is selected. To get all the sticker data, create_gengrid() calls sticker_consumer_data_foreach_all().

      static void
      sticker_info_cb(sticker_data_h data_handle, void *user_data)
      {
         int ret;
         sticker_data_uri_type_e type;
      
         // Gets the URI and URI type of the sticker
         ret = sticker_data_get_uri(data_handle, &type, &sticker_path[idx]);
         if (ret != STICKER_ERROR_NONE)
         {
            // Do something
         }
      
         idx++;
      }
      
      static Evas_Object*
      create_gengrid(appdata_s *ad, api_type type)
      {
         .....
      
         idx = 0;
         switch (type)
         {
         case FOREACH_ALL:
            ret = sticker_consumer_data_foreach_all(g_ch, 0, STICKER_MAX, &result, sticker_info_cb, NULL);
            if (ret != STICKER_ERROR_NONE)
            {
               // Do something
            }
         break;
      
         .....
      
         evas_object_show(gengrid);
      
         return gengrid;
      }