- 浏览: 174943 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (140)
- java (138)
- 佳能500d (1)
- 佳能 (1)
- Oracle数据库文档构造器--Oraschemadoc (1)
- EJB调用的原理分析 (1)
- 使用css3画"静音"icon (1)
- 张小庆,在路上(16)-给弟弟找工作 (1)
- Android短信编解码方式 (1)
- lua web 开发 (1)
- zk安装 (1)
- 菜单多国语言化遇到的问题 (1)
- 【转】纯文本配置还是注册表 (1)
- C++ delete删除动态分配的内存 (1)
- eclipse下修改项目名导致tomcat内发布名不一致的解决方法 (1)
- Lucene实现各种常见文档的全文检索 (1)
- 项目风险之人员流动风险 (1)
- 时空数据模型简介 (1)
- XSLT学习笔记 (1)
- 依然是计划 如果没有计划似乎就没有了动力 (1)
- How to Succeed in A Professional Career (1)
- 编程环境应该和讨论社区完美的进行结合 (1)
- C#坦克大战实现 (1)
- 电脑用户密码忘记了怎么办? (1)
- java.lang.NoClassDefFoundError: org/dom4j/DocumentException (1)
- 关于成立北京Android爱好者俱乐部的声明 (1)
- Android开发之初探音频的播放 (1)
- Struts标签循环List (1)
- CAP原理 (1)
- javabean的自动生成 (1)
- 打开CMD一闪就关的解决方案 (1)
- 我是项目经理,我的项目管理日记【20111202】 (1)
- Html5游戏开发入门笔记--<躲砖块> (1)
- mysql中查看和设置系统字符编码 (1)
- PhoneGap-Accelerometer (1)
- [Jetty]Jetty工作原理 (1)
- Ibatis+Spring整合实例Demo+源码 (1)
最新评论
-
u012985907:
dsdsdsdsd
FLASH上传与拍照 -头像-avatart -
a379933101:
?????????????????????????????
android listview 连续调用 getview问题分析及解决 -
151tmac:
拜托下次粘贴的时候,粘贴为纯文本
android listview 连续调用 getview问题分析及解决 -
liudezhong135:
...
Spring3MVC 在JSP中使用@ModelAttribute -
香飘飘2011:
要是不知道层次级别,如何退回到根目录呢
FTP退回到根目录
采集设备在x、y、z方向上的动作。
accelerometer.getCurrentAcceleration accelerometer.watchAcceleration accelerometer.clearWatch
accelerometerSuccess accelerometerError accelerometerOptions
Acceleration
accelerometer.getCurrentAcceleration
返回当前沿x、y和z方向的加速度。
navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速计可以检测沿X、Y和Z轴的三维运动。
加速度数据通过accelerometerSuccess回调函数返回。
支持的平台:
Android
BlackBerry WebWorks (OS 5.0或更高版本)
iPhone
function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n'); } function onError() { alert('onError!'); } navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
<!DOCTYPE html> <html> <head> <title>Acceleration Example</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8"> // 等待加载PhoneGap document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap加载完毕 function onDeviceReady() { navigator.accelerometer.getCurrentAcceleration(onSuccess, onError); } // onSuccess: 返回当前加速度数据的快照 function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n'); } // onError: 返回加速度数据失败 function onError() { alert('onError!'); } </script> </head> <body> <h1>Example</h1> <p>getCurrentAcceleration</p> </body> </html>
iPhone的特异情况:
iPhone没有获取在任何给定点当前加速度数据的概念。
你必须通过给定时间间隔查看加速度并获得数据。
因此,getCurrentAcceleration函数会返回从phoneGap watchAccelerometer调用开始后的最近一个返回值。
accelerometer.watchAcceleration
在固定的时间间隔获取沿x、y和z轴的加速度。
var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess, accelerometerError, [accelerometerOptions]);
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的动作传感器。加速计可以检测沿X、Y和Z轴的三维运动。
accelerometer.watchAcceleration每隔固定时间就获取一次设备的当前加速度。每次取得加速度后,accelerometerSuccess回调函数会被执行。通过acceleratorOptions对象的frequency参数可以设定以毫秒为单位的时间间隔。
返回的watch id是加速度计监视周期的引用,可以通过accelerometer.clearWatch调用该watch ID以停止对加速度计的监视。
支持的平台:
Android
BlackBerry WebWorks (OS 5.0或更高版本)
iPhone
function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n'); } function onError() { alert('onError!'); } var options = { frequency: 3000 }; // 每隔3秒更新一次 var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
<!DOCTYPE html> <html> <head> <title>Acceleration Example</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8"> // watch id 是当前“watchAcceleration”的引用 var watchID = null; // 等待加载PhoneGap document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap加载完毕 function onDeviceReady() { startWatch(); } // 开始监视加速度 function startWatch() { // 每隔3秒钟更新一次加速度数据 var options = { frequency: 3000 }; watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); } // 停止监视加速度 function stopWatch() { if (watchID) { navigator.accelerometer.clearWatch(watchID); watchID = null; } } // onSuccess: 获取当前加速度数据的快照 function onSuccess(acceleration) { var element = document.getElementById('accelerometer'); element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' + 'Acceleration Y: ' + acceleration.y + '<br />' + 'Acceleration Z: ' + acceleration.z + '<br />' + 'Timestamp: ' + acceleration.timestamp + '<br />'; } // onError: 获取加速度失败 function onError() { alert('onError!'); } </script> </head> <body> <div id="accelerometer">Waiting for accelerometer...</div> </body> </html>
iPhone的特异情况:
在请求的时间间隔,PhoneGap将调用success回调指向的函数,并传递加速度计数据。
不过,PhoneGap将对设备的请求间隔时间限制为最小40ms,最大1000ms。
例如,如果你设定每隔3秒(3000毫秒)请求一次,PhoneGap仍然每隔1秒请求一次设备,但是每隔3秒才调用一次success回调函数。
accelerometer.clearWatch
停止watch ID参数指向的加速度监视。
navigator.accelerometer.clearWatch(watchID);
watchID:由accelerometer.watchAcceleration返回的引用标识ID。
支持的平台:
Android
BlackBerry WebWorks (OS 5.0或更高版本)
iPhone
var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); // ... 后续处理 ... navigator.accelerometer.clearWatch(watchID);
<!DOCTYPE html> <html> <head> <title>Acceleration Example</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8"> // watch id 是当前“watchAcceleration”的引用 var watchID = null; // 等待加载PhoneGap document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap加载完毕 function onDeviceReady() { startWatch(); } // 开始监视加速度 function startWatch() { // 每隔3秒钟更新一次加速度数据 var options = { frequency: 3000 }; watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options); } // 停止监视加速度 function stopWatch() { if (watchID) { navigator.accelerometer.clearWatch(watchID); watchID = null; } } // onSuccess: 获取当前加速度数据的快照 function onSuccess(acceleration) { var element = document.getElementById('accelerometer'); element.innerHTML = 'Acceleration X: ' + acceleration.x + '<br />' + 'Acceleration Y: ' + acceleration.y + '<br />' + 'Acceleration Z: ' + acceleration.z + '<br />' + 'Timestamp: ' + acceleration.timestamp + '<br />'; } // onError: 获取加速度失败 function onError() { alert('onError!'); } </script> </head> <body> <div id="accelerometer">Waiting for accelerometer...</div> <button onclick="stopWatch();">Stop Watching</button> </body> </html>
Acceleration
包含特定时间点采集到的加速计数据。
属性:
x:在X轴的运动量,[0, 1]范围(数字类型)
y:在Y轴的运动量,[0, 1]范围(数字类型)
z:在Z轴的运动量,[0, 1]范围(数字类型)
timestamp:以毫秒为单位的创建时间戳。(DOMTimeStamp类型)
说明:
这个对象是由phoneGap创建和填充,并由Acce这个对象是由PhoneGap创建和填充,并由Accelerometer的方法返回。
支持的平台:
Android
BlackBerry WebWorks (OS 5.0或更高版本)
iPhone
function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n'); } function onError() { alert('onError!'); } navigator.accelerometer.getCurrentAcceleration(onSuccess,onError);
<!DOCTYPE html> <html> <head> <title>Acceleration Example</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8"> // 等待加载PhoneGap document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap加载完毕 function onDeviceReady() { navigator.accelerometer.getCurrentAcceleration(onSuccess, onError); } // onSuccess: 获得加速度数据的快照 function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n'); } // onError: 获取加速度失败 function onError() { alert('onError!'); } </script> </head> <body> <h1>Example</h1> <p>getCurrentAcceleration</p> </body> </html>
accelerometerSuccess
提供加速度信息的onSuccess回调函数。
function(acceleration) { // 进一步处理 }
参数:
acceleration: 在某一时刻的加速度(Acacceleration:在某一时刻的加速度。(Acceleration对象类型)
function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n');
accelerometerError
加速度方法的onError回调函数。
复制
function() { // 错误处理 }
accelerometerOptions
定制检索加速度计的可选参数。
选项:
frequency:多少毫秒获取一次Acceleration。(数字类型)(默认值:10000)
发表评论
-
Ibatis+Spring整合实例Demo+源码
2012-02-08 12:58 1391<span style="color: ... -
[Jetty]Jetty工作原理
2012-02-07 17:29 988http://www.ibm.com/develo ... -
mysql中查看和设置系统字符编码
2012-02-04 14:28 1701--查看数据库的字符集 show variables ... -
Html5游戏开发入门笔记--<躲砖块>
2012-02-03 12:04 1162学习了html5中的canvas画布元素,自己写了一个 ... -
我是项目经理,我的项目管理日记【20111202】
2012-02-03 10:19 985其实前段时间项目 ... -
打开CMD一闪就关的解决方案
2012-02-02 12:14 1377转:http://blog.163.com/cumt_ ... -
javabean的自动生成
2012-02-02 11:59 1386在jcreator pro中自动生成 在j ... -
CAP原理
2012-02-01 09:00 1140作者:NinGoo 原文链接:ht ... -
Struts标签循环List
2012-01-31 14:18 955<pre name="code&quo ... -
Android开发之初探音频的播放
2012-01-11 16:29 1078<h1>Android开发之初探音频的播放 ... -
关于成立北京Android爱好者俱乐部的声明
2012-01-11 14:33 856<blockquote dir="lt ... -
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
2011-12-28 13:03 15082<span style="font-f ... -
电脑用户密码忘记了怎么办?
2011-12-28 12:14 973<span style="fon ... -
C#坦克大战实现
2011-12-20 13:29 1107记得在大学学java ... -
编程环境应该和讨论社区完美的进行结合
2011-12-19 11:54 754在学习.NET过程中,经常会遇到很多问题,有的时候会找 ... -
How to Succeed in A Professional Career
2011-12-19 10:29 724(From Microsoft)<br>& ... -
依然是计划 如果没有计划似乎就没有了动力
2011-12-15 10:39 871</span></span>& ... -
XSLT学习笔记
2011-12-14 14:04 657<p class="MsoNorma ... -
时空数据模型简介
2011-12-14 13:59 1474<p class="MsoNo ... -
项目风险之人员流动风险
2011-12-13 12:29 1170<p class="MsoNorma ...
相关推荐
PhoneGap - API 中文说明 Accelerometer 加速度计 Camera 相机 Capture 捕捉 Compass 指南针 Contacts 联系人 Device 设备 Events 活动 File 文件 Geolocation 地理位置 Media 媒体 Network 网络 Notification 通知...
PhoneGap - API 中文说明 Accelerometer 加速度计 Camera 相机 Capture 捕捉 Compass 指南针 Contacts 联系人 Device 设备 Events 活动 File 文件 Geolocation 地理位置 Media 媒体 Network 网络 Notification 通知...
PhoneGap,API帮助文档翻译整理1-Accelerometer(加速度计)
《Apress Beginning PhoneGap》 源码 PhoneGap-Accelerometer PhoneGap-Accelerometer-Image PhoneGap-Android-GWT-Hellworld PhoneGap-Camera PhoneGap-Compass PhoneGap-DeviceInfo 等
PhoneGap——Accelerometer【加速计】
phoneGap可以通过对象accelerometer得到手机的加速度,本项目示例可以学习怎么得到手机当前时间的加速度和定时间间隔周期性得到手机加速度
Table of Contents •Determining Whether the Device Is Ready •Retrieving Information About the Device •Creating a Persistent Navigation System ...•Extending PhoneGap with Plug-ins
Incorporate smartphone capabilities such as GPS, camera, accelerometer, and more into your apps for any mobile platform Use Cordova view to embed PhoneGap into native applications to either transit ...
PhoneGap开发必备 PhoneGap Mobile Application Development Cookbook Preface 1 Chapter 1: Movement and Location: Using the Accelerometer and Geolocation Sensors 7 Introduction 7 Detecting device ...
Use PhoneGap to hook into advanced Android features -- including the accelerometer, geolocation, and alerts Test and debug your app on the Web under load with real users, and then submit the ...
However, there are still two things that it cannot do: it can’t access the device features and hardware (e.g., geolocation, accelerometer, sound, and vibration) and it can’t be submitted to the ...
Using the QuickConnect JavaScript API to perform tasks ranging from vibrating the phone to accessing the accelerometer and GPS location data Accessing native iPhone functionality using the PhoneGap ...
With the help of straightforward, real-world examples, you’ll learn to build apps from the Cordova CLI and to make use of native device features like the camera and accelerometer. You’ll learn ...
Use PhoneGap to hook into advanced Android features — including the accelerometer, geolocation, and alerts Test and debug your app on the Web under load with real users, and then submit the finished ...
#Rikulo Gap 是 Dart 中移动框架(又名 PhoneGap)的桥接实现。 它使开发人员能够使用 HTML、CSS 和 Dart 访问多个移动平台的本机设施。Rikulo Gap 在 Apache 2.0 许可下分发。 ##从 Dart Pub 存储库安装将此添加到...
You’ll find guidelines for converting your product into a native iPhone app using the free PhoneGap framework. And you’ll learn why releasing your product as a web app first helps you find, fix, ...
3. Accelerometer 4. JQuery 5. JQuery plugin example JQuery 插件示例使用: JQuery 插件骰子可以在任何网页中使用。 使用 JQuery 类骰子,我们可以向指定的选择器启动一个动画骰子对象。 var dice1 = $("#dice...