我正在为Samsung Gear开发Tizen Web App。 (使用Tizen 2.4)
当前,我尝试添加一个功能,该功能允许用户通过手表打开手机上的链接。 因此,当他按下按钮时,URL将在手机的默认浏览器中打开。我注意到其他智能手表应用程序都具有此功能。
浏览这些论坛后,我找到了一个代码示例:
var appControl = new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/view',
'https://www.tizen.org', null, null, null, null);
tizen.application.launchAppControl(appControl, null, function() {
console.log('launch application control succeed');
}, function(e) {
console.log('launch application control failed. reason: ' + e.message);
}, null);
但是,当我尝试运行它时,出现以下错误:"launch application control failed. reason: No matched application found."
我的应用确实在其配置文件中添加了以下特权:
<tizen:privilege name="http://tizen.org/privilege/application.info"/>
<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
答案 0 :(得分:0)
找到了 您将需要application.launch特权。
function openBrowserOnPhone(url) {
var appid = "com.samsung.w-manager-service";
var type = "phone";
var extra_data = [
new tizen.ApplicationControlData("msgId", ["mgr_install_host_app_req"]),
new tizen.ApplicationControlData("type", [type]),
new tizen.ApplicationControlData("deeplink", [url])];
var appControl = new tizen.ApplicationControl(
"http://tizen.org/appcontrol/operation/default",
null,
null,
null,
extra_data);
var appControlReplyCallback = {
onsuccess: function(data) {
console.log("launchUrl reply success");
console.log("success: data = " + JSON.stringify(data));
},
onfailure: function() {
console.log("launchUrl reply failed");
}
};
try {
tizen.application.launchAppControl(
appControl,
appid,
function() { console.log("intentBorba", "launchUrl success"); },
function(err) { console.log("intentBorba", "launchUrl failed: " + err.message); },
appControlReplyCallback);
}catch(err) {
console.error("[launcher] " + err);
}
}