From: Andrzej Popowski Code example: Parameters: Code example: Parameters: Code example: Code example: Parameters: Parameters: var appEventCallback = {
- oninstalled: function(appInfo) {
- console.log('The application ' + appInfo.name + ' is installed');
- },
- onupdated: function(appInfo) {
- console.log('The application ' + appInfo.name + ' is updated');
- },
- onuninstalled: function(appid) {
- console.log('The application ' + appid + ' is uninstalled');
- }
+ oninstalled: function(appInfo) {
+ console.log('The application ' + appInfo.name + ' is installed');
+ },
+ onupdated: function(appInfo) {
+ console.log('The application ' + appInfo.name + ' is updated');
+ },
+ onuninstalled: function(appid) {
+ console.log('The application ' + appid + ' is uninstalled');
+ }
};
var watchId = tizen.application.addAppInfoEventListener(appEventCallback);
tizen.application.removeAppInfoEventListener(watchId);
@@ -1465,11 +1465,11 @@ System events do not require an application identifier to be specified. Therefor
@@ -1493,12 +1493,25 @@ System events do not require an application identifier to be specified. Therefor
var app = tizen.application.getCurrentApplication();
- // for user events: sender's application ID and event name must be provided by using a dictionary
- // Let's assume that there is another application installed with id "a234567890.TestWidget"
- var watchId = app.addEventListener({"appId": "a234567890.TestWidget", "name": "custom_user_event"}, function(event, data) {
- console.log("Data: " + JSON.stringify(data));
- // do something
- });
+ // for user events: sender's application ID and event name must be provided by using a dictionary
+ // Let's assume that at least two applications are installed
+ function onListInstalledApps(appsInfo) {
+ var appId = null;
+
+ if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) {
+ appId = appsInfo[0].id;
+ } else if (appsInfo.length > 1) {
+ appId = appsInfo[1].id;
+ }
+
+ if (appId) {
+ var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) {
+ console.log("Data: " + JSON.stringify(data));
+ // do something
+ });
+ }
+ }
+ tizen.application.getAppsInfo(onListInstalledApps);
@@ -1532,16 +1545,30 @@ System events do not require an application identifier to be specified. Therefor
var watchId, app = tizen.application.getCurrentApplication();
+
var app = tizen.application.getCurrentApplication();
- function eventListenerCallback(event, data) {
- console.log("Data: " + JSON.stringify(data));
- // do something and then remove the listener
- app.removeEventListener(watchId);
+ // for user events: sender's application ID and event name must be provided by using a dictionary
+ // Let's assume that at least two applications are installed
+ function onListInstalledApps(appsInfo) {
+ var appId = null;
+ var watchId = null;
+
+ if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) {
+ appId = appsInfo[0].id;
+ } else if (appsInfo.length > 1) {
+ appId = appsInfo[1].id;
+ }
+
+ if (appId) {
+ watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, function(event, data) {
+ if (watchId) {
+ app.removeEventListener(watchId);
+ watchId = null;
+ }
+ });
+ }
}
-
- // Let's assume that there is another application installed with id "a234567890.TestWidget"
- watchId = app.addEventListener({"appId": "a234567890.TestWidget", "name": "custom_user_event"}, eventListenerCallback);
+ tizen.application.getAppsInfo(onListInstalledApps);
@@ -1624,11 +1651,11 @@ An application can listen to events from other applications. However, it can onl
@@ -2027,19 +2054,6 @@ required action requested by the calling application.
Since:
2.0
Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); - if (reqAppControl) { - console.log("Requester AppID : " + reqAppControl.callerAppId); - - var appControl = reqAppControl.appControl; - if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") { - var data = new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/selected", ["Image1.jpg"]); - reqAppControl.replyResult([data]); - } - } --
Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); + if (reqAppControl) { + console.log("Requester AppID : " + reqAppControl.callerAppId); + + var appControl = reqAppControl.appControl; + if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") { + var data = new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/selected", ["Image1.jpg"]); + reqAppControl.replyResult([data]); + } + } ++
replyFailure
@@ -2133,6 +2160,18 @@ to perform the requested action.
+Code example:
var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); + if (reqAppControl) { + console.log("Requester AppID : " + reqAppControl.callerAppId); + + var appControl = reqAppControl.appControl; + if (appControl.operation == "http://tizen.org/appcontrol/operation/pick") { + reqAppControl.replyFailure(); + } + } ++
Code example:
function onListInstalledApps(applications) { + for (var i = 0; i < applications.length; i++) + console.log("ID : " + applications[i].id); + } + + tizen.application.getAppsInfo(onListInstalledApps); ++
Code example:
var appControl = new tizen.ApplicationControl( + "http://tizen.org/appcontrol/operation/pick", + null, + "image/jpeg", + null); + + // FindAppControlSuccessCallback instance + function successCB(appInfos, appControl) + { + // appControl is same object with the value passed as first parameter to findAppControl() + var appControlReplyCallback = { + // callee sent a reply + onsuccess: function(data) { + for (var i = 0; i < data.length; i++) { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") { + console.log('Selected image is ' + data[i].value[0]); + } + } + }, + // callee returned failure + onfailure: function() { + console.log('The launch application control failed'); + } + } + + var appId = appInfos[0].id; // select first app's id + + tizen.application.launchAppControl( + appControl, + appId, + function() {console.log("launch application control succeed"); }, + function(e) {console.log("launch application control failed. reason: " + e.message); }, + appControlReplyCallback ); + } + + tizen.application.findAppControl(appControl, successCB); ++
Code example:
var appControl = new tizen.ApplicationControl( + "http://tizen.org/appcontrol/operation/pick", + null, + "image/jpeg", + null); + + // ApplicationControlDataArrayReplyCallback instance + var appControlReplyCallback = { + // callee sent a reply + onsuccess: function(data) { + for (var i = 0; i < data.length; i++) { + if (data[i].key == "http://tizen.org/appcontrol/data/selected") { + console.log('Selected image is ' + data[i].value[0]); + } + } + }, + // callee returned failure + 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 ); ++
Code example:
var appEventCallback = { + oninstalled: function(appInfo) { + console.log('The application ' + appInfo.name + ' is installed'); + }, + onupdated: function(appInfo) { + console.log('The application ' + appInfo.name + ' is updated'); + }, + onuninstalled: function(appid) { + console.log('The application ' + appid + ' is uninstalled'); + } + }; + var watchId = tizen.application.addAppInfoEventListener(appEventCallback); ++
Parameters:
Code example:
var app = tizen.application.getCurrentApplication(); + + // for user events: sender's application ID and event name must be provided by using a dictionary + // Let's assume that at least two applications are installed + function onListInstalledApps(appsInfo) { + var appId = null; + + if (appsInfo.length > 0 && app.appInfo.id != appsInfo[0].id) { + appId = appsInfo[0].id; + } else if (appsInfo.length > 1) { + appId = appsInfo[1].id; + } + + var eventCB = function(event, data) { + console.log("Data: " + JSON.stringify(data)); + // do something + }; + + if (appId) { + var watchId = app.addEventListener({"appId": appId, "name": "custom_user_event"}, eventCB); + } + } + tizen.application.getAppsInfo(onListInstalledApps); ++