Delphi Xe7 up1 call android vibrate function
The vibration is used in the following 4 units:
Androidapi.jni.app,androidapi.jnibridge,androidapi.jni.os,androidapi.helpers
How to use :
Var
Lvibrator:jvibrator;
Begin
Lvibrator: = Tjvibrator.wrap
((Sharedactivity.getsystemservice (TJActivity.JavaClass.VIBRATOR_SERVICE)
As Ilocalobject). Getobjectid); Call Vibration
If not Lvibrator.hasvibrator then
Begin
ShowMessage (' mobile phone does not support vibration ');
Exit;
End
Lvibrator.vibrate (500); Vibrating in milliseconds
Finally set Uses Permissions in Project Options to set vibrate to true
The detailed procedures are as follows:
Unit Unit6;
Interface
Uses
System.sysutils, System.types, System.uitypes, system.classes, System.variants,androidapi.jni.app,
FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, Fmx.stdctrls,
Androidapi.jnibridge,androidapi.jni.os,androidapi.helpers;
Type
TFORM6 = Class (Tform)
Button1:tbutton;
Procedure Button1Click (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End
Var
FORM6:TFORM6;
Implementation
{$R *.FMX}
Procedure Tform6.button1click (Sender:tobject);
Var
Lvibrator:jvibrator;
Begin
Lvibrator: = Tjvibrator.wrap
((Sharedactivity.getsystemservice (TJActivity.JavaClass.VIBRATOR_SERVICE)
As Ilocalobject). Getobjectid); Call Vibration
If not Lvibrator.hasvibrator then
Begin
ShowMessage (' mobile phone does not support vibration ');
Exit;
End
Lvibrator.vibrate (500); Vibrating in milliseconds
End
End.
Delphi Xe7 up1 call Android vibrate function