Delphi Xe7 up1 call Android vibrate function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.