语言

Menu
Sites
Language
Launch popup from native service application

Hi All,

I am a beginner in Tizen and here is the scenario I am considering to resolve.

Through native service which is running in background I want to give periodic pop up to user's device about the service results. The service fetches data from internet periodically (the "period" is entered by user which I am handling in webapp which is linked to service). I need to show this data as a popup. 

How can I achieve this ?

It'll be great if someone could help.

 

Thanks

编辑者为: Dheeraj Khoriya 25 3月, 2015

响应

14 回复
Alex Dem

Hi,
In service app it is not possible to show UI.I think you should launch another app and show popup there.
Alexey.

Dheeraj Khoriya

Ok, I realised the same after a while.

As you suggested about launching other app from service, I can launch the webapp from service app (service and webapp are linked and service is launched from within webapp itself). Is there any way I can differentiate between the launching method of webapp as there will be two.

1. when webapp gets launched by user by clicking on the icon (main UI will be showed)

2. when webapp is launched by service app (let say, service app shows a notification, clicking upon which the webapp will be launched) - in this case I can only show part of UI i.e. popup which should not get run in the previous scenario.

 

Thanks.

Alex Dem

I suppose you should define your web app as App conrol also:
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.appprogramming/html/guide/app_guide/exporting_appcontrol.htm
in config.xml will be additional section, something like this:

<tizen:app-control>
   <src name="popup.html"/>
   <operation name="http://tizen.org/appcontrol/operation/yourOperation"/>
</tizen:app-control>

or you should try to use common operation as: http://tizen.org/appcontrol/operation/view instead of.
In this case tag 'src' will be another entry point. 
After this you should launch web app using 'app control' functionality from native service ( here is example for explicit launch from native app, if your operation 'view'):

    app_control_h app_control;
    app_control_create(&app_control);
    app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
    app_control_set_app_id(app_control, "yourWebAppId");
    app_control_send_launch_request(app_control, NULL, NULL);

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/guide/app/app_controls.htm
After these steps content which was defined in 'popup.html' will be displayed.
Alexey.

Alex Dem

Please don't forget add privilege: 
http://tizen.org/privilege/appmanager.launch
into manifest of native service also.
Alexey.

Dheeraj Khoriya

Hi Alex,

Thanks for the info.

I also wanted to know that once we send some data too with the appcontrol from service app by using 

app_control_add_extra_data(app_control_h app_control, char *key, char* value);

how do we retrieve it in the webapp when it gets launched because along with launching the application I also want to get the data and then show it in the popup.html ? Any ideas about it ?

Also when I add in the config.xml

<tizen:app-control>
    	<operation name="http://tizen.org/appcontrol/operation/view" />
		<src name="popup.html" ></src>
</tizen:app-control>

the following error shows up: "One of '{"http://www.w3.org/ns/widgets":src, ... is expected."

Will it run fine even after this error? because build is getting successful.

Dheeraj Khoriya

actually the build is also getting failed

Alex Dem

Hi,
regarding second issue:
I did not observe such error but I have got another. And I was able to run app with my error on emulator. But better to avoid errors you could try to configure App Control via 'Tizen' tab of config.xml (or write 'src' as one tag).
In source it will be looks like this:

    <tizen:app-control>
        <tizen:src name="popup.html"/>
        <tizen:operation name="http://tizen.org/appcontrol/operation/view"/>
    </tizen:app-control>


Alexey.

Dheeraj Khoriya

tried that already Alexey. still didn't work. 

And you have any idea about the first issue, as in how to send and receive some data while launching webapp using appcontrol ?

Alex Dem

Regarding second issue :
You could try to send extra data this way:
On native app side please add also:
    app_control_add_extra_data(app_control, "myKey","myValue");
on web app site you could extarct data this way on start:

    var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl();
    if (reqAppControl) {
        var appControl = reqAppControl.appControl;
        if(reqAppControl.callerAppId == "org.tizen.yourServiceApp")
        {
            if (appControl.operation == "http://tizen.org/appcontrol/operation/view")
            {
                console.log(appControl.data[0].key);
                console.log(appControl.data[0].value);                
            }            
        }
    }

And one more link: https://developer.tizen.org/documentation/articles/handling-requested-application-control
Alexey.

Dheeraj Khoriya

I still get that config.xml error. which SDK are you using ? I am using Version : 2.3.0_Rev2 
Build id : 20150121-1703.

 

Alex Dem

I use 2.3.0_Rev2 installed on Win 7 64 bit.
Alexey.

 

Dheeraj Khoriya

That is exactly same as mine. But I am testing it on device. 

Dheeraj Khoriya

It gives error. But it is working fine. If you happen to come across the solution towards the error, please let me know.

 

Thanks.

Dheeraj

Alex Dem

Hi,
I have no errors in my example, but maybe you could share your config.xml as is?
Alexey.