如何在动作脚本中检测设备目标类型?

时间:2019-12-30 03:10:34

标签: bixby bixbystudio

我希望我的“ GetContent”脚本检测设备是否在“监视”状态,并传递一条指令以从content.json文件中过滤出候选答案,该文件的文本字段长度大于一定数目的字符。

content.json格式:

{tags: ["literature"], text: "At once it struck me what quality went to form a man of achievement, especially in literature, and which Shakespeare possessed so enormously -- I mean negative capability, that is, when a man is capable of being in uncertainties, mysteries, doubts, without any irritable reaching after fact and reason. Source: John Keats", image: {url: "images/Shakespeare.jpg"}},

所以逻辑应该是

if (watch) content = short_quotes_only

2 个答案:

答案 0 :(得分:1)

我建议您探索deviceDocumentation)的$vivContext属性

通过device属性,您可以查看用户使用的设备类型(bixby-mobile,bixby-tv等),并提供希望显示的数据。 / p>

答案 1 :(得分:0)

这些摘要片段对我有用:

for (var i = 0; i < Model.updatedDatas.Count; i++)
{
    <tr>
         <td>
              @Html.DisplayFor(modelitem => modelitem.updatedDatas[i].TagName)
              @Html.HiddenFor(modelitem => modelitem.updatedDatas[i].TagName)
         </td>
    </tr>
}

然后在脚本中稍后

  device = $vivContext.device
  console.log('device', device)

  if (device == 'bixby-watch' ) { maxlength = 100
  console.log('maxlength is now', maxlength)
  }