Delphi Mobile Phone Vibrate IOS Android

Source: Internet
Author: User

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

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.