如何在 Ubuntu SDK 中使用 Apache Cordova API

如何在 Ubuntu SDK 中使用 Apache Cordova API

我在 Ubuntu-SDK 中创建了一个 HTML5 应用。因此我转到了“新建项目”->“Ubuntu”->“HTML5 应用”。该应用已经可以运行,但现在我想使用振动来为用户提供对某个按键的反馈。

我找到的唯一资源是:https://developer.ubuntu.com/api/html5/sdk-14.04/org.apache.cordova.vibration/

但当我执行时,cordova plugin add org.apache.cordova.vibration我得到了这个Current working directory is not a Cordova-based project.。而当我只是使用时navigator.notification.vibrate(2500);什么也没有发生。

有人能帮助我如何访问 cordova API 吗?

Qt Creator的版本是3.1.1(基于5.2.1)。操作系统是Ubuntu 14.04。

答案1

为了使用 Cordova API,您需要按照此处所述创建一个 Cordova 应用程序:

https://developer.ubuntu.com/en/apps/html-5/tutorials/cordova-camera-app-tutorial/

Cordova 应用程序及其开发流程尽可能接近 Cordova 开发人员所习惯的流程,并且目前与 QtCreator 的 HTML5 应用程序工作流程分开。

尽管 w3c 振动 API(navigator.vibrate)应该可以开箱即用,但这是 Oxide(我们的 webview 后端)目前的一个缺点,我添加了一个错误来跟踪此处的问题:

https://bugs.launchpad.net/oxide/+bug/1440863

相关内容