Languages

Menu
Sites
Language
how can i make a share function, like on android platform

Now, i have a text or a photo, i want to make a share function to use other app sending out it.

How can i do this work?

I notice, tizen provide ApplicationControl api, you can find special app with operation url, for example:"http://tizen.org/appcontrol/operation/share".

And then you can interaction with the requested app.

Now, i meet a problem, after i lunched the shareApp. i can't get requestedAppControl in shareApp.

it's my code of shareApp: app always log null

var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl();
 
console.log(reqAppControl);
 
if (reqAppControl) {
    console.log(reqAppControl.appControl);
    reqAppControl.replyResult('text');
}

and it's my code of main app:

var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/share", null,"image/*", null);
 
var appControlReplyCallback = {
    // callee sent a reply
    onsuccess : function(data) {
        for ( var i = 0; i < data.length; i++) {
            console.log("#" + i + " key:" + data[i].key);
            for ( var j = 0; j < data[i].value.length; j++) {
                console.log("   value#" + j + ":" + data[i].value[j]);
           }
        }
    },
    // Something went wrong
    onfailure : function() {
    console.log('The launch application control failed');
    }
}
 
tizen.application.launchAppControl(appControl, null, function() {
    console.log("launch application control succeed");
}, function(e) {
    console.log("launch application control failed. reason: " + e.message);
}, appControlReplyCallback);

 

Anybody can help me?

And how can i transfer data between the two app?

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

4 Replies
Lakshmi Grandhi
Hi, I am lokking into your post , will get back
Alex Dem
On latest Tizen SDK Version : 2.1.0 it works OK. your share App should contains next rules in config.xml file (for example): ... ... shareImages.html should includes main.js file with next code (for example): ... var onLoad = function () { var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); console.log(JSON.stringify(reqAppControl)); }; window.onload = onLoad; ... //------------------------------------------------------------- so you could start "share App" from "main App" this way: ... var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/share", null, "image/*", null); tizen.application.launchAppControl(appControl, null, function() { console.log("launch application control succeed"); }, function(e) { console.log("launch application control failed. reason: " + e.message); }, appControlReplyCallback); ... share App->onLoad method will be executed: reqAppControl will contains: {"appControl":{"data":[],"mime":"image/*","category":null,"uri":null,"operation":"http://tizen.org/appcontrol/operation/share"},"callerAppId":"TlbvhM3vkZ.mainApp"} Please try to migrate your applications on Tizen 2.1.0
Alex Dem
missed text in prev post (just remove "_")... your share App should contains next rules in config.xml file (for example): ... <_tizen:app-control> <_tizen:src name="shareImages.html"/> <_tizen:operation name="http://tizen.org/appcontrol/operation/share"/> <_tizen:mime name="image/*"/> <_/tizen:app-control> ...
Raghavendra Reddy Shiva
Just making more clearer on (how to access data) the app side, which gets the control passed and need to retrieve the passed or shared data.. First get the app control as below, var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); And now access the data using the key/value pair, if (reqAppControl) { var reqData = reqAppControl.appControl.data; console.log("App ctrl Key: " + reqData[0].key+" Data:"+reqData[0].value); //Update the index for more key/value pairs }