• delphi 手机振动 IOS Android


    delphi  手机振动 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/

    IOS方法

    #import <AudioToolbox/AudioToolbox.h>
    调用方法
    SystemSoundID soundID;
    kSystemSoundID_Vibrate是常量$FFF

    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
     

    delphi 方法

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    unit Umain;
     
    interface
     
    uses
      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 500 milliseconds
      Vibrator.vibrate(500);
    {$ENDIF}
    {$IFDEF IOS}
      AudioServicesPlaySystemSound( kSystemSoundID_vibrate );
    {$ENDIF}
    end;
     
    end.

    添加库方法  

    ios must Add Path

    RAD IDE>Tools>Options>SDK Manager>IOS 系统SDK

    点击 右侧按钮>Add a new path item.

    Path on remote machine:$(SDKROOT)/System/Library/Frameworks

    File mask:AudioToolbox

    Path type:Other Path

    Include subdirectories:

     点 OK>Update Local File Cache

    windows系统电脑能看到更新到的AudioToolbox功能文件。

    D:UsersAdministratorDocumentsEmbarcaderoStudioSDKsiPhoneOS9.1.sdkSystemLibraryFrameworksAudioToolbox.frameworkHeaders

     

    参考

    http://blog.csdn.net/tht2009/article/details/50183721

    报错

    [DCC Error] E2597 ld: warning: directory not found for option 
    '-FE:UsersAdministratorDocumentsEmbarcaderoStudioSDKsiPhoneOS9.3.sdkSystemLibraryPrivateFrameworks'
      ld: file not found: /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox

    解决方法:

    1、收到建立目录PrivateFrameworks

    2、删除windows目录E:UsersAdministratorDocumentsEmbarcaderoStudioSDKsiPhoneOS9.3.sdk。

        然后关闭IDE,删除IDE里3个SDK。然后重新下载,先下载ios32位,添加AudioToolbox库,更新缓存,再依次更新64位。

  • 相关阅读:
    【zzuli-2276】跳一跳
    哈夫曼编码
    【zzuli-2266】number(二进制处理)
    【51nod-1042】数字0-9的数量
    【51nod-1009】数字1的数量
    数据库第八次实验
    【zzuli-1923】表达式求值
    vue组件父子组件传递引用类型数据
    JS中的call()方法和apply()方法用法总结
    Object.assign()与深拷贝(一)
  • 原文地址:https://www.cnblogs.com/westsoft/p/8437956.html
Copyright © 2020-2023  润新知