简体   繁体   English

Tizen Gear Web应用程序,使用文本数据启动Web应用程序

[英]Tizen gear web app, launch web app with text data

I have a watch face that launches another app using the code below: 我的表盘可以使用以下代码启动另一个应用程序:

var appId ="aGbGC3smHe.apptwo"; // app to be launched 

tizen.application.launch(appId); 

It works, but I want to send text from the watch face to the second app and have the second app do something with it like below 它可以工作,但是我想将文本从表盘发送到第二个应用程序,并让第二个应用程序执行以下操作

if (senttext === "hello"){
console.log("hello")
}

I saw this code which I think might be half the answer but I dont know how to deal with the text at the other end.... 我看到了这段代码,我认为这可能只是答案的一半,但我不知道如何处理另一端的文本。

var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/share",null,"text/*",null ,[new tizen.ApplicationControlData("text", [message])]);

tizen.application.launchAppControl(appControl, null,function()console.log("launch application control succeed");
},function(e) {alert("ERROR")});

can I please know how to do this in Tizen Web? 我可以知道如何在Tizen Web中执行此操作吗? ... Thank you :) ... 谢谢 :)

You may try the steps below: 您可以尝试以下步骤:

  1. Use the code below in the Watch Application(Watch face app) 在Watch应用程序(Watch face应用程序)中使用以下代码

 var obj = new tizen.ApplicationControlData("Paste_Your_Watch_Face_APP_ID_Here", ["Hello"]); var obj1 = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/default", null, null, null, [obj] ); tizen.application.launchAppControl(obj1, "aGbGC3smHe.apptwo", function() {console.log("Launch Service succeeded"); }, function(e) {console.log("Launch Service failed : " + e.message);}, null); 

  1. Use the code below in the second app. 在第二个应用程序中使用下面的代码。 Now, if you click on the word "Basic" it'll show the data sent from the Watch App. 现在,如果您单击“基本”一词,它将显示从Watch App发送的数据。

  var mainPage = document.querySelector('#main'); mainPage.addEventListener("click", function() { var contentText = document.querySelector('#content-text'); var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); if (reqAppControl) { var reqData = reqAppControl.appControl.data; for (var i = 0; i < reqData.length; i++) { console.log("#" + i + " key:" + reqData[i].key); for (var j = 0; j < reqData[i].value.length; j++) { console.log(" value#" + j + ":"+reqData[i].value[j]); // Process the data contentText.innerHTML = reqData[i].value[j]; } } } }); 

Hope it'll help! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM