Delphi调用android振动功能


本文整理自网络,侵删。

 
uses
  Androidapi.JNI.App, Androidapi.JNIBridge, Androidapi.JNI.Os,
  Androidapi.Helpers;
var
  LVibrator: JVibrator;
begin
  LVibrator := TJVibrator.Wrap
    ((SharedActivity.getSystemService(TJActivity.JavaClass.VIBRATOR_SERVICE)
    as ILocalObject).GetObjectID); // 调用振动
  if not LVibrator.hasVibrator then
  begin
    ShowMessage('手机不支持震动');
    Exit;
  end;
  LVibrator.vibrate(500); // 振动500毫秒
end;

权限
在Project Options中设置Uses Permissions将Vibrate设为true

相关阅读 >>

Delphi 获得用android应用程序触摸到的位置(坐标)的方法

Delphi一个抓屏的函数

Delphi 时间增加一小时的技巧

Delphi 随机指定范围的字符串函数

Delphi修改资源文件的代码

Delphi 木马配置器通用写法(末尾追加数据的方法)

Delphi xe 移动平台 showmodal 范例

Delphi xe7 ios 取得系统字型名称

Delphi 基础学习指定字符替换其他字符

Delphi 将string 转为 array of ansichar

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...