文档库 最新最全的文档下载
当前位置:文档库 › 震动api对应关系

震动api对应关系

震动api对应关系
震动api对应关系

Android public abstract class Vibrator extends Object 页面链接https://www.wendangku.net/doc/f918293406.html,/reference/a ndroid/os/Vibrator.html?q=Vibrator#q=Vib rator 比较常用的api对应cancel()Turn the vibrator off.hasVibrator()Check whether the hardware has a vibrator.vibrate (long[] pattern, int repeat, AudioAttributes attributes)Vibrate with a given pattern.vibrate(long[] pattern, int repeat)Vibrate with a given pattern.vibrate(long milliseconds)Vibrate constantly for the specified period of time.vibrate (long milliseconds, AudioAttributes attributes)Vibrate constantly for the specified period of

time.

简单说明

除hasVibrator()外其他函数都需要VIBRATE权

Allows access to the vibrator

Constant Value:

"android.permission.VIBRATE"

void 在下载的

程序里没

见过在下载的

程序里没

见过abstract void

abstract boolean

void

void

void

ios

System Sound Services Reference

页面链接

https://https://www.wendangku.net/doc/f918293406.html,/library/ios/documentation/AudioToolbox/Reference/S ystemSoundServicesReference/#//apple_ref/c/tdef/AudioServicesSystemSoundComple tionProc

AudioServicesCreateSystemSoundID

AudioServicesDisposeSystemSoundID

AudioServicesPlayAlertSound

AudioServicesPlaySystemSound

AudioServicesAddSystemSoundCompletion

AudioServicesRemoveSystemSoundCompletion

AudioServicesGetPropertyInfo

AudioServicesGetProperty

AudioServicesSetProperty

AudioServicesSystemSoundCompletionProc

enum {

kSystemSoundID_Vibrate = 0x00000FFF

};

其他常量未列出

相当于在系统声音相关的方法里只有一个方法可以提供系统震动的功能AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);单次震动持续1-2s

连续震动实现方法(可看参考工程中answer-vibration)AudioServicesAddSystemSoundCompletion(kSystemSoundID_Vibrate, NULL, NULL, systemAudioCallback, NULL);

AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate);

这两个接口的用途是绑定和取消指定soundID对应的回调方法;kSystemSoundID_Vibrate 为soundID类型,其回调方法认准的也是这个soundID,在任何地方使用这个id去执行AudioServicesPlaySystemSound(xxxSoundID)都会调用到该回调方法。而一旦调用remove 方法取消回调,同样的在任何地方使用这个id去执行AudioServicesPlaySystemSound(xxxSoundID)都不会调用到这个回调。说的这么绕,其实就是说这俩接口的影响是全局的,威力很大。

我们只要在回调方法里面再调用AudioServicesPlaySystemSound接口,就可以实现连续震动了;当我们想要停止震动时,调用remove接口,ok,回调方法就歇火了。

相关文档