Languages

Menu
Sites
Language
Passing arguments to application

Hi,

I would like to know how to pass arguments to the application from command line or from eclipse.

Is there a way to acheive this?

Thanks,

 

 

Responses

5 Replies
woochan lee

Hello,

Could you please explain what you want more detaily?

What is the arguments?  why do you want to pass arguments to the application? 

Alex Dem

Hi,
fyi, As I know you could try to run 'sdb shell' (here is for Win example) with C:\tizen-sdk\tools>sdb -d shell 
and try to launch app this way and set key/val:
sh-3.2$ launch_app <pkgname> <key1> <val1> <key2> <val2> ...
Alexey.

Alex Dem

Hi,
I was able to print args inside : main(int argc, char *argv[])

for (int i=0; i<argc; i++)
{
    dlog_print(DLOG_ERROR, LOG_TAG, "app_main() arg[%d] = %s",i, argv[i]);
}

If I have added one pair key/val (count was increased from 8 to10). I able to print 'key' as is, but value looks like encrypted (or something else) . In any case I did not face any docs about how to use launch_app for this case.
Alexey.

Hermet Park

since the launch pad data is encrypted, you need to decode the data again,

You could use the app_control for this,

Please check app_control()

static void

app_control(app_control_h app_control, void *data)

{

 

}

plus, this API.

int app_control_foreach_extra_data(app_control_h app_control, app_control_extra_data_cb callback, void *user_data);

 

app_control cb is registered to ui_app_lifecycle_callback_s which is described in the application template code.

 

Mil Tolstoy

As I can see, it's not encrypted, it's just encoded using base64.

 

1. Run your app though launch_app:

$sdb shell launch_app com.example.my_app my_param my_value

2. Get argument value from main():

my_param: IgAAAAEEAAAJAAAAbXlfcGFyYW0ACQAAAG15X3ZhbHVlAA==

3. Perform base64 decode:

    3.1 Manually by using some website just for test

    "�����    ���my_param�    ���my_value�

    3.2 In your app using glib, which exists in Tizen SDK - g_base64_decode()

 

Of course, you should write some additional code to decode and parse this string, but it's look easier that using app_control_foreach_extra_data().