Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
8_组件-传感器
Search
powerhope
August 11, 2016
0
120
8_组件-传感器
App Inventor移动应用开发
powerhope
August 11, 2016
Tweet
Share
More Decks by powerhope
See All by powerhope
1_App Inventor初步
powerhope
0
190
2_1_HelloPurr
powerhope
0
130
2_2_8-Ball(魔术8球)
powerhope
2
120
3_App Inventor编程基础
powerhope
0
100
4_组件-用户界面
powerhope
0
140
5_组件-界面布局
powerhope
0
140
6_组件-多媒体
powerhope
0
89
7_组件-绘图动画
powerhope
0
110
9_组件-社交应用
powerhope
0
140
Featured
See All Featured
A Tale of Four Properties
chriscoyier
150
22k
The Art of Programming - Codeland 2020
erikaheidi
40
12k
Visualization
eitanlees
135
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
113
18k
Gamification - CAS2011
davidbonilla
76
4.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.2k
Facilitating Awesome Meetings
lara
39
5.5k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
178
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
14
1.3k
Designing for Performance
lara
601
67k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
Transcript
College of Mathematics and Computer Science, Hunan Normal University 瞿绍军
湖南师范大学数学与计算机科学学院
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
一直计时(TimerAlwaysFires ):如果选中,计时将一直伴随 应用,甚至在应用尚未在屏幕上 显示时,计时就开始了。 启用计时(TimerEnabled): 如果选中,则开始计时。 计时间隔(TimerInterval): 触发计时器计时事件的时间间隔 ,单位为毫秒,1秒=1000毫秒 。 计时器(Clock)
College of Mathematics and Computer Science, Hunan Normal University
在计时器启动后,每经过一个“计时间隔”就会触 发该事件一次。 计时器事件
College of Mathematics and Computer Science, Hunan Normal University 设定日期和时间格式
设日期时间格式(FormatDateTime):用指定模 式的文本表示某一时刻的日期和时间。如 “MM/dd/yyyy hh:mm:ss a”,其中M代表月,d代 表日,y代表年,代表小时,m代表分钟,s代表秒 ,a代表上、下午,S代表毫秒。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 创建时间点
由毫秒创建时间点(MakeInstantFromMillis): 将指定的毫秒数转换为时刻,毫秒数从1970年开 始计算。 由文本创建时间点(MakeInstant):将文本格式 指定的时间(如“MM/DD/YYYY hh:mm:ss 或 MM/DD/YYYY 或 hh:mm”)转换为时刻。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 增加时间
增加年数(AddYears):在给定时刻增加指定的 年数。 增加月数(AddMonths):在给定时刻增加指定 的月数。 增加天数(AddDays):在给定时刻增加指定的天 数。 增加时数(AddHours):在给定时刻增加指定的 小时数。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University
增加分数(AddMinutes):在给定时刻增加指定 的分钟数。 增加秒数(AddSeconds):在给定时刻增加指定 的秒数。 增加周数(AddWeeks):在给定时刻增加指定的 周数。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University
求时间 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 持续时间
ddDuration:返回某个时间点持续指定毫秒后的 时间。 DurationToSeconds:转换持续时间(毫秒)为 秒数。 DurationToMinutes:转换持续时间(毫秒)为 分钟数。 DurationToHours:转换持续时间(毫秒)为小 时数。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University
DurationToDays:转换持续时间(毫秒)为天 数。 DurationToWeeks:转换持续时间(毫秒)为周 数。 这里的持续时间均为毫秒数,比如一天24小时就 是24*60*60*1000=86400000毫秒。 计时器方法
College of Mathematics and Computer Science, Hunan Normal University
秒表 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 组件
所属组件组 命名 用途 属性 水平布局1 界面布局 水平布局1 居中显示“标签_时间” 组件 水平对齐:居中 宽度:充满 标签 用户界面 标签_时间 动态显示时间 文本:空 按钮 用户界面 按钮_秒表 秒表开始计时 文本:开始计时 标签 用户界面 标签_秒表 动态显示秒表 文本:空 计时器 传感器 计时器_时间 用于显示时钟 启用计时:选中 计时间隔:10 计时器 传感器 计时器_秒表 用于显示秒表 启用计时:不选 计时间隔:100 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 计时器方法
College of Mathematics and Computer Science, Hunan Normal University 计时器方法
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
非可视组件,可以侦测到摇晃,并测出三个维度上 的加速度分量的近似值,单位为米/秒2(m/s2)。 三 个分量为: xAccel: 当手机在平面上静止时,其值为零;当手 机向左倾斜时(即,右侧升起),其值为正;而向右 倾斜时(左侧升起),其值为负。 yAccel: 当手机在平面上静止时,其值为零;当手 机顶部抬起时,其值为正;而当底部抬起时,其值 为负。 加速度传感器AccelerometerSensor
College of Mathematics and Computer Science, Hunan Normal University
zAccel: 当设备屏幕朝上地静止在与地面平行的平 面上时,其值为9.8(地球的重力加速度);当垂直于 地面时,其值为0;当屏幕朝下时,其值为-9.8。 无论是否由于重力的原因,让手机加速运动,就会 改变它的加速度分量值。 加速度传感器AccelerometerSensor
College of Mathematics and Computer Science, Hunan Normal University
最小间隔( MinimumInterval):检 测两次手机摇晃的最小间 隔。 敏感度(Sensitivity): 加速计的敏感程度,有三 个选项:1=弱;2=中等 ;3=强。 加速度传感器AccelerometerSensor
College of Mathematics and Computer Science, Hunan Normal University 加速度传感器AccelerometerSensor
College of Mathematics and Computer Science, Hunan Normal University
方向传感器用于确定手机的空间方位,该组件为非 可视组件,以角度的方式提供下面三个方位值: 翻转角:当设备水平放置时,其值为0°;并随着 向左倾斜到竖直位置时,其值为90°,而当向右倾 斜至竖直位置时,其值为-90°。 方位角 : 当设备顶部指向正北方时,其值为0°, 正东为90°,正南为180°,正西为270°。 方向传感器OrientationSensor
College of Mathematics and Computer Science, Hunan Normal University
倾斜角 : 当设备水平放置时,其值为0°;随着设 备顶部向下倾斜至竖直时,其值为90°,继续沿相 同方向翻转,其值逐渐减小,直到屏幕朝向下方的 位置,其值变为0°;同样,当设备底部向下倾斜 直到指向地面时,其值为-90°,继续沿同方向翻 转到屏幕朝上时,其值为0°。 方向传感器OrientationSensor
College of Mathematics and Computer Science, Hunan Normal University
效果 贪食球-方向传感器
College of Mathematics and Computer Science, Hunan Normal University
界面设计 贪食球-方向传感器
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
提供位置信息的非可视组件,提供的信息包括:纬 度、经度、高度(如果设备支持)及街区地址,也可 以实现“地理编码”,即,将地址信息(不必是当前 位置)转换为纬度及经度。 为了实现这些功能,组件的启用属性值必须为真, 并且通过WiFi或者GPS(如果在户外)开启设备的位 置传感器。 位置传感器LocationSensor
College of Mathematics and Computer Science, Hunan Normal University
间距(DistanceInterval):决定了传感器尝试使 用发送位置更新的最小距离间隔,单位为米。如设 置间距为5,则每走过5米,传感器就会触发一次“ 位置被更改”事件。然后,传感器不能保证恰好在指 定间距的位置接收到更新信息,也可能在超过5米 的地方触发事件。 时间间隔(TimeInterval):以毫秒为单位设定最 小时间间隔,传感器将以此间隔发出位置更新信息 。然而,手机的实际位置必须发生变化,传感器才 能收到新的位置信息,指定的时间间隔并不能保证 按时收到位置信息。 位置传感器属性
College of Mathematics and Computer Science, Hunan Normal University
位置被更改(LocationChanged):表明已经检 测到新的位置信息。 状态被改变(StatusChanged):表明位置提供者 的服务状态发生了变化,如当提供者丢失或新的提 供者开始被使用。 位置传感器事件
College of Mathematics and Computer Science, Hunan Normal University
由地址求纬度(LatitudeFromAddress):从给定 的地址推算纬度值。 由地址求经度(LongitudeFromAddress):从给 定的地址推算经度值。 位置传感器方法
College of Mathematics and Computer Science, Hunan Normal University 获取经纬度信息
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
Barcode Scanner条码扫描器本身没有扫描功能, 需要调用其它条码扫描软件(zxing扫描软件), zxing扫描软件能够直接读取条码中存储的信息、 数字和网址的条码扫描器,方便快捷查找记录! 下载: http://market.91.com/android/com.google.z xing.client.android.htm 条码扫描器BarcodeScanner
College of Mathematics and Computer Science, Hunan Normal University
使用条码扫描器来读取条码的组件。 条码扫描器BarcodeScanner
College of Mathematics and Computer Science, Hunan Normal University 条码扫描器BarcodeScanner
College of Mathematics and Computer Science, Hunan Normal University 图书扫描
College of Mathematics and Computer Science, Hunan Normal University 图书扫描
College of Mathematics and Computer Science, Hunan Normal University
启动条码扫描 图书扫描
College of Mathematics and Computer Science, Hunan Normal University
通过豆瓣的API访问图书信息,其API地址为: http://api.douban.com/v2/book/isbn/XXXX XXXX为扫描到的ISBN号 这里显示的图书信息不适合手机端 豆瓣的移动站点是 https://m.douban.com/book/subject/XXXX/ XXXX为图书的Subject号 所以要通过ISBN获取到对应的Subject,需先使用 Web客户端获取豆瓣的API数据。 图书扫描
College of Mathematics and Computer Science, Hunan Normal University
扫描结束后 图书扫描
College of Mathematics and Computer Science, Hunan Normal University 图书扫描
College of Mathematics and Computer Science, Hunan Normal University
API解析 返回的数据为JSON格式,这里我们关心的是 subject参数,也就是id参数。 然后将Web客户端获取的数据通过JSON解析后, 找到对应的id。 图书扫描
College of Mathematics and Computer Science, Hunan Normal University 图书扫描
College of Mathematics and Computer Science, Hunan Normal University
提供近场通信(Near Field Communication)能力 的非可视组件,目前该组件只支持文字信息的读写( 如果设备也同时支持)。 NFC近场通信
College of Mathematics and Computer Science, Hunan Normal University
近距离传感器是通过红外线进行测距,当手机用户 接听电话或者装进口袋时,传感器可以判断出手机 贴近了人的脸部或者衣服而关闭屏幕的触控功能, 这样就可以防止误操作。 近距离传感器可以测量目标相对于设备的屏幕的距 离(cm)的传感器组件。这个传感器通常用于确定是 否有手机被举到人耳,如,允许您确定从设备到目 标有多远。很多设备返回的是绝对距离(cm),但 有些设备返回的是远、近值。在这种情况下,传感器 通常报告在远的状态它的最大范围值和在近的状态 一个较小的值。 近距离传感器
College of Mathematics and Computer Science, Hunan Normal University
KeepRunningWhenOnPause:如果设置为真,即 使应用程序是不可见的,它将保持传感距离变化。 即可以在组件设计视图中设定,也可以在逻辑设计 视图中设定。 近距离传感器
College of Mathematics and Computer Science, Hunan Normal University 近距离传感器
College of Mathematics and Computer Science, Hunan Normal University
陀螺仪传感器是一个简单易用的基于自由空间移动 和手势的定位和控制系统,它原本是运用到直升机 模型上,现已被广泛运用于手机等移动便携设备。 陀螺仪传感器是非可视组件,在三维空间中可以测 量角速度,单位是度每秒。为了使用该功能,组件 的启用属性要设置为true,设备必须有陀螺仪传感器 。 陀螺仪传感器GyroscopeSenso
College of Mathematics and Computer Science, Hunan Normal University
GyroscopeChanged:当陀螺仪传感器的数据发生 改变时触发该事件。返回的参数是X、Y、Z轴角速 度和时间戳,时间戳是事件在纳秒时发生的。1纳 秒等于十亿分之一秒。 陀螺仪传感器GyroscopeSenso
College of Mathematics and Computer Science, Hunan Normal University 陀螺仪传感器GyroscopeSenso
College of Mathematics and Computer Science, Hunan Normal University
College of Mathematics and Computer Science, Hunan Normal University
实验7:设计制作指南针。 实验