Delphi Mobile Phone Vibrate IOS Android
Https://community.embarcadero.com/blogs/entry/how-to-vibrate-ios-and-android-phones-using-firemonkey-and-xe8
http://blogs.embarcadero.com/davidi/2015/07/06/43894/
Unit umain;interfaceuses system.sysutils, System.types, System.uitypes, system.classes, System.variants, FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, FMX. Controls.presentation, FMX. stdctrls{$IFDEF ANDROID}, Androidapi.JNI.Os, Androidapi.JNI.GraphicsContentViewText, Androidapi.helpers, androidapi.jnibridge{$ENDIF} {$IFDEF IOS}, Iosapi.mediaplayer, Iosapi.coregraphics, FMX. Platform, FMX. Platform.ios, Iosapi.uikit, Macapi.objcruntime, Macapi.objectivec, Iosapi.cocoatypes, Macapi.CoreFoundation, IOSapi. Foundation, Iosapi.coreimage, Iosapi.quartzcore, iosapi.coredata{$ENDIF}; {$IFDEF IOS} Const libaudiotoolbox = '/system/library/frameworks/audiotoolbox.framework/audiotoolbox '; Ksystemsoundid_vibrate = $FFF; Procedure Audioservicesplaysystemsound (Insystemsoundid:integer); CDECL; External libaudiotoolbox Name _pu + ' audioservicesplaysystemsound '; {$ENDIF}type TForm1 = Class (Tform) Button1:tbutton; Procedure Button1Click (Sender:tobject); Private {déclarations privées} public {déclarations publiques} end;var form1:tform1;implementation{$R *.FMX }procedure Tform1.button1click (Sender:tobject); {$IFDEF ANDROID} Var Vibrator:jvibrator; {$ENDIF}begin{$IFDEF ANDROID} vibrator:=tjvibrator.wrap ((Sharedactivitycontext.getsystemservice ( TJContext.JavaClass.VIBRATOR_SERVICE) as Ilocalobject). Getobjectid); Vibrate for milliseconds vibrator.vibrate (500); {$ENDIF} {$IFDEF IOS} Audioservicesplaysystemsound (ksystemsoundid_vibrate); {$ENDIF}end;end.
Delphi Mobile Phone Vibrate IOS Android