Languages

Menu
Sites
Language
Getting result from filemanager

Hi all,

I had launched filemanager succesfully from my app with operation pick, but i am not able to get the selected file name , i came accross the app_control_result but i dont know how to implement it, can any one tell me how to get the app control launch results

Regards
Harish K 

Responses

11 Replies
Vikram

Hi, maybe below sample code can help you. call this function in the app_control_result callback. Register the callback in function app_control_send_launch_request()

app_control_get_extra_data(reply, APP_CONTROL_DATA_SELECTED, &value)

You can get detailed help from 

https://developer.tizen.org/documentation/dev-guide/2.3.0

and Launching Applications section on IDE help, Tizen Mobile Native App Programming > Programming Guide > Application Framework: Controlling Your Application > Application Fundamentals

harish kumar kavali

Hi 
           Thanks  for your reply, i already came across that tutorial, but i dont know how to register the app_control_request call back, can you please explain in detail.
            
Regards
Harish K

Vikram

Hi,

The returned key should be "path", but not the "APP_CONTROL_DATA_SELECTED" as my previous comments. I just to foreach the extra date on the "app_control reply", details as below sample code.

static bool
foreach_extra_data_cb(app_control_h app_control, const char *key, void *user_data)
{
    char *value;
	int ret;

	ret = app_control_get_extra_data(app_control, key, &value);
    if ( ret == APP_CONTROL_ERROR_NONE)
    {
        dlog_print(DLOG_INFO, LOG_TAG, "[app_control_extra_data_cb] Succeeded: key(%s), value(%s)", key, value);
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_extra_data_cb] Failed: key(%s), Error code: %d", key, ret);
        return FALSE;
    }
	return TRUE;
}

/* Callback function to get result */
static void
file_select_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
	char *value;
    int ret;

    if (result == APP_CONTROL_RESULT_SUCCEEDED)
    {
	    ret = app_control_get_extra_data(reply, "path", &value);
        if ( ret == APP_CONTROL_ERROR_NONE)
        {
            dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb] Succeeded: value(%s)", value);
        }
        else
        {
            dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] Failed, Error code: %d", ret);
        }
        //app_control_foreach_extra_data(reply, foreach_extra_data_cb, NULL);
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED. Error code: %d", result);
    }
}
static void
btn_file_select_cb(void *data, Evas_Object *obj, void *event_info)
{
	app_control_h app_control;
	int ret;

	app_control_create(&app_control);
	app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK);
	app_control_set_mime(app_control, "image/*"); // or, app_control_set_mime(app_control, "*/*");
    ret = app_control_send_launch_request(app_control, file_select_result, NULL);
	if ( ret == APP_CONTROL_ERROR_NONE)
	{
	   dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch a file manager picker app.");
	}
	else
	{
	   dlog_print(DLOG_ERROR, LOG_TAG, "Failed to launch a file manager picker app. error code: %d", ret);
	}

	app_control_destroy(app_control);
}
/* open file manager to pick a file */
static Evas_Object*
test_AppControl(appdata_s *ad)
{
	Evas_Object *button;

	button = elm_button_add(ad->conform);
	elm_object_text_set(button, "Select a File");
	evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, 0);
	evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
	evas_object_smart_callback_add(button, "clicked", btn_file_select_cb, NULL);

	return button;
}

 

harish kumar kavali

Hi ,
for both "path" & 

APP_CONTROL_DATA_SELECTED

it is giving same error -126 ENOKEY


 

colin Rao

Hi,

I can get the selected file via "path". 

dlog:

04-09 09:18:27.020 : INFO / test ( 4487 : 4487 ) : Succeeded to launch a file manager picker app.
04-09 09:18:32.750 : INFO / test ( 4487 : 4487 ) : [app_control_result_cb] Succeeded: value(/opt/usr/media/DCIM/Camera/20150408-164242.jpg)

code:

/* Callback function to get result */
static void
file_select_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
    char *value;
    int ret;

    if (result == APP_CONTROL_RESULT_SUCCEEDED)
    {
	    ret = app_control_get_extra_data(reply, "path", &value);
        if ( ret == APP_CONTROL_ERROR_NONE)
        {
            dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb] Succeeded: value(%s)", value);
        }
        else
        {
            dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] Failed, Error code: %d", ret);
        }
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED. Error code: %d", result);
    }
}

 

harish kumar kavali

Hi,

I am using the following code  and getting the following error

04-09 10:06:58.453 : INFO / mkavach ( 32696 : 32696 ) : Succeeded to launch a viewer app.
04-09 10:07:03.653 : ERROR / mkavach ( 32696 : 32696 ) : [app_control_result_cb] Failed, Error code: -126

my manifest file privileges
        

 <privilege>http://tizen.org/privilege/mediastorage</privilege>
        <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        <privilege>http://tizen.org/privilege/externalstorage</privilege>

 

Please help me if i am missing any thing

 

static void app_control_result(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
{
    char *value;
        int ret;

        if (result == APP_CONTROL_RESULT_SUCCEEDED)
        {
            ret = app_control_get_extra_data(reply, "path", &value);
            if ( ret == APP_CONTROL_ERROR_NONE)
            {
                dlog_print(DLOG_INFO, LOG_TAG, "[app_control_result_cb] Succeeded: value(%s)", value);
            }
            else
            {
                dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] Failed, Error code: %d", ret);
            }
        }
        else
        {
            dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_result_cb] APP_CONTROL_RESULT_FAILED. Error code: %d", result);
        }
}

static void
launch_file_manager_cb(void *data, Evas_Object *obj, void *event_info)
{
    elm_object_text_set(obj, "Clicked!");

      app_control_h app_control;

      app_control_create(&app_control);
      app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK);
      app_control_set_mime(app_control, "*/*");

      if (app_control_send_launch_request(app_control, app_control_result, NULL) == APP_CONTROL_ERROR_NONE)
      {
         dlog_print(DLOG_INFO, LOG_TAG, "Succeeded to launch a viewer app.");

      }
      else
      {
         dlog_print(DLOG_ERROR, LOG_TAG, "Failed to launch a viewer app.");
      }


      app_control_destroy(app_control);
}

 

harish kumar kavali

Hi ,

"path"  is working  for

app_control_set_mime(app_control, "image/*");

but giving error when i use

app_control_set_mime(app_control, "*/*");

 

colin Rao

Hi,

Maybe the key is diffreent in these cases ( mime: */*, mime: image/*). 

Suggest to iteration the keys on the respond app_control "reply" as Vikram's coments "BY Vikram, 8 Apr 2015, 02:34" to check the difference.

Additional,

I am testing the code on Z1, and can't run it on emulator.

colin Rao

Hi,

By iteration the extra data by mime type "*/*" as Vikram's comments "BY Vikram, 8 Apr 2015, 02:34", I get below dlog, 

Process, click on button to open file manager viewer,  select My Files > DCIM > Camera > "select an image" > DONE

Seems, in this scenario, the reply a key "APP_CONTROL_DATA_SELECTED" with empty/null value. 

04-09 15:41:21.210 : INFO / test ( 3934 : 3934 ) : [app_control_extra_data_cb]
04-09 15:41:21.210 : ERROR / test ( 3934 : 3934 ) : [app_control_extra_data_cb] Failed: key(http://tizen.org/appcontrol/data/selected), Error code: -126

Also, I've tried another process, open file manager viewer, select Gallery > "select an image", in this case I get the the selected image via "path".

 

harish kumar kavali

here i am able to select only image files via "path" but not other files, ihad tried with "APP_CONTROL_DATA_SELECTED" for selecting  even this condition also fails
had any one succeded in selecting files via app control 
Regards
Harish 

 

 

colin Rao

Hi,

Try to iterate the extra data to check the actually output in your case. Maybe the key is something else in your case.

example: 

static bool
foreach_extra_data_cb(app_control_h app_control, const char *key, void *user_data)
{
    char *value;
	int ret;

	ret = app_control_get_extra_data(app_control, key, &value);
    if ( ret == APP_CONTROL_ERROR_NONE)
    {
        dlog_print(DLOG_INFO, LOG_TAG, "[app_control_extra_data_cb] Succeeded: key(%s), value(%s)", key, value);
    }
    else
    {
        dlog_print(DLOG_ERROR, LOG_TAG, "[app_control_extra_data_cb] Failed: key(%s), Error code: %d", key, ret);
        return FALSE;
    }
	return TRUE;
}

// call it in your file selected callback
app_control_foreach_extra_data(reply, foreach_extra_data_cb, NULL);