Delphi XE5 Android 调用手机震动
uses
Androidapi.JNI.Os,
Androidapi.JNIBridge; function GetVibratorArray(const AIntArr: array of Int64): TJavaArray<Int64>;
var
LIndex: Integer;
begin
Result := TJavaArray<Int64>.Create(Length(AIntArr));
for LIndex := Low(AIntArr) to High(AIntArr) do
Result.Items[LIndex] := AIntArr[LIndex];
end; procedure VibratorTest;
var
LVibrator: JVibrator;
LJavaArray: TJavaArray<Int64>;
begin
{ Vibrator概要:
cancel(): 关闭震动
hasVibrator():检查硬件是否支持
vibrate(long milliseconds): 震动milliseconds毫秒
vibrate(long[] pattern, int repeat):按给定数组震动 } { 需要开启Vibrator权限 }
LVibrator := TJVibrator.Create as JVibrator; { 测试手机是否支持震动 }
if not LVibrator.hasVibrator then
begin
ShowMessage('手机不支持震动');
Exit;
end; { Test procedure vibrate(milliseconds: Int64); cdecl; overload; } { 效果A: 立即震动 800 毫秒 }
// LVibrator.vibrate(); { Test procedure vibrate(pattern: TJavaArray<Int64>; repeat_: Integer); cdecl; overload;
pattern: 为震动数组参数,偶数代表等待时间(ms), 奇数代表震动持续时间(ms)
repeat_: -1: 只震动一遍; > -1: 从Index为 repeat_ 的位置开始重复震动 } { 创建测试数组 }
LJavaArray := GetVibratorArray([, , , ]); { 效果B: 等待500毫秒 -> 震动1秒 -> 等待2秒 -> 震动3秒 }
// LVibrator.vibrate(LJavaArray, -); { 效果C: 效果B重复震动 }
// LVibrator.vibrate(LJavaArray, ); { 取消震动(当手机暗屏或锁屏时会自动取消) }
// LVibrator.cancel; { 效果D: (等待500毫秒 -> 震动1秒 -> 等待2秒 -> 震动3秒)(先按原顺序震动一遍)
接着循环 [1000, 2000, 3000]
->(等待1秒 -> 震动2秒 - > 等待3秒)
->[等待1秒 -> 等待2秒 ... ]
这个听上去的效果像( 等待4秒 -> 震动2秒 )}
// LVibrator.vibrate(LJavaArray, ); { 效果E: (先按原顺序执行一遍), 接着不会震动(偶数为等待时间) }
// LVibrator.vibrate(LJavaArray, ); { 效果F: 当然是报IndexOutBounds异常 }
// LVibrator.vibrate(LJavaArray, {!!!}); end;
Delphi XE5 Android 调用手机震动的更多相关文章
- Delphi XE5 Android 调用手机震动(通过JObject测试是否支持震动)
源码如下: uses Androidapi.JNI.Os, Androidapi.JNIBridge; function GetVibratorArray(const AIntArr: array o ...
- Delphi XE5 Android 调用 Google ZXing
{ Google ZXing Call demo Delphi Version: Delphi XE5 Version 19.0.13476.4176 By: flcop(zylove619@hotm ...
- delphi xe5 android 调用照相机获取拍的照片
本篇文章我们来看一下delphi xe5 在android程序里怎样启动照相机并获取所拍的照片,本代码取自xe自带打sample,路径为: C:\Users\Public\Documents\RAD ...
- 学习使用Delphi for android 调用Java类库
http://blog.csdn.net/laorenshen/article/details/41148253 学习使用Delphi for android 调用Java类库 2014-11-15 ...
- html5调用手机震动
在h5里面里面,浏览器对象有个vibrate属性.顾名思义,翻译过来就是震动的意思,这个api属性方法如下: 要调用的例子 if (window.navigator.vibrate) window.n ...
- Unity3d之音效播放和调用手机震动
http://blog.csdn.net/sunshine_1984/article/details/12943979 今天研究了下Unity3d音效播放相关内容,整理下实现细节. 1,添加音效文件到 ...
- delphi xe5 android iny绿色版+最新SDK/NDK安装方法
转自: http://bbs.2ccc.com/topic.asp?topicid=438595 首先感谢iny的绿色版,因为我的精简Win7 32位安装原版镜像4.63G过程正常,但是编译出错,后来 ...
- delphi xe5 android 服务端和手机端的源码下载
xe5 android的服务端和手机客户端的源代码下载地址 http://files.cnblogs.com/nywh2008/AndroidTest.rar
- xe5 android 调用照相机获取拍的照片[转]
本篇文章我们来看一下delphi xe5 在android程序里怎样启动照相机并获取所拍的照片,本代码取自xe自带打sample,路径为: C:\Users\Public\Documents\RAD ...
随机推荐
- 调用系统命令 os.system()和os.popen()
Python中os.system和os.popen区别 Python调用Shell,有两种方法:os.system(cmd)或os.popen(cmd)脚本执行过程中的输出内容.实际使用时视需求情况而 ...
- 『计算机视觉』Mask-RCNN_训练网络其一:数据集与Dataset类
Github地址:Mask_RCNN 『计算机视觉』Mask-RCNN_论文学习 『计算机视觉』Mask-RCNN_项目文档翻译 『计算机视觉』Mask-RCNN_推断网络其一:总览 『计算机视觉』M ...
- Matlab:高阶常微分三种边界条件的特殊解法(中心差分法,高精度导数边界处理)
函数文件1: function b=F(f,x0,h,N) % b(1,1)=x0(1)-h*x0(2)-u(1); % b(2,1)=x0(2)+h*x0(1)^2-u(2)-h*f; b=zero ...
- java 常见语法,但是发现switch等基础,常见面试套路不会了,待补充
1,面向对象,万物皆对象,面向对象的三个基本特性:封 装,继承,多态. 面向对象的程序都是由类组成,类封装了对象的属性和行为. 封装:隐藏对象的属性和实现细节,仅对外提供接口. 继承:实现代码复用,将 ...
- layer中每次用到都要查来查去的功能
1.关闭当前弹出层 var index = parent.layer.getFrameIndex(window.name); setTimeout(function(){parent.layer.cl ...
- @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 注解的作用
在学习boot 项目的时候 ,发现在启动类中有一个这个的注解 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) ...
- go web framework gin 路由表的设计
在上一篇go web framework gin 启动流程分析这一篇文章中,我分析了go gin启动的过程,在这一篇文章中我将继续上面的分析,讨论gin 中路由表是如何设计的? 首先查看engine. ...
- Oracle 创建存储过程 提示权限不足或者提示表和视图不存在问题
grant create view to hospital; --授予查询权限 grant select any table to hospital; --授予权限 grant select any ...
- TensorFlow Training 优化函数
tf.train 提供了一组帮助训练模型的类和函数. 优化器 优化器基类提供了计算渐变的方法,并将渐变应用于变量.子类的集合实现了经典的优化算法,如 GradientDescent和Adagrad. ...
- linux中ls -l介绍
[root@localhost ~]# ls -l 总计 152 -rw-r--r-- 1 root root 2915 08-03 06:16 a -rw------- 1 root root 10 ...