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 ttask无法传递参数的一个解决方案

Delphi button 实现下拉列表

Delphi for 循环 to和downto的理解

Delphi获取我的文档路径

Delphi监控文件夹

Delphi写进程管理器

Delphi delete 删除字符串中指定的字符串

Delphi 端口扫描器原理

Delphi tms web core messagedlg对话框用法

Delphi 快捷键设置控件: thotkey

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



打赏

取消

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

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

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

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

评论

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