android[Api]Vibrator_振动器

来源:互联网 发布:微时代营销软件 编辑:程序博客网 时间:2024/05/01 07:47

Class Overview


设备上的振动器控制类

如果你的进程退出,你将会停止任何设置了的震动

获得系统振动器的一个实例,调用 getSystemService(String) VIBRATOR_SERVICE 为参数

Summary


Public Methodsabstract voidcancel()

Turn the vibrator off.
关闭震动器abstract booleanhasVibrator()

Check whether the hardware has a vibrator.

检查硬件是否有一个振动器。
abstract voidvibrate(long[] pattern, int repeat)

Vibrate with a given pattern.
振动的模式
abstract voidvibrate(long milliseconds)
Vibrate constantly for the specified period of time.
指定震动的时间长度。
[Expand]
Inherited Methods
 From class java.lang.Object

Public Methods


public abstract void cancel ()

Added in API level 1

Turn the vibrator off.

关掉振动器。

This method requires the caller to hold the permission VIBRATE.

这种方法要求调用方允许振动。

public abstract boolean hasVibrator ()

Added in API level 11

Check whether the hardware has a vibrator.

检查硬件是否有一个振动器。

Returns
  • True if the hardware has a vibrator, else false.

public abstract void vibrate (long[] pattern, int repeat)

Added in API level 1

Vibrate with a given pattern.

设置震动的模式

Pass in an array of ints that are the durations for which to turn on or off the vibrator in milliseconds. The first value indicates the number of milliseconds to wait before turning the vibrator on. The next value indicates the number of milliseconds for which to keep the vibrator on before turning it off. Subsequent values alternate between durations in milliseconds to turn the vibrator off or to turn the vibrator on.

To cause the pattern to repeat, pass the index into the pattern array at which to start the repeat, or -1 to disable repeating.

This method requires the caller to hold the permission VIBRATE.

传入的整数数组的持续时间来打开或关闭振动器,以毫秒为单位。第一个值表示将振动器之前等待的毫秒数。下一个值表示震动的毫秒数,之后振动器将其关闭。随后值之间的交替时间以毫秒为单位,关掉振动器或启动振动器。

Parameters
patternan array of longs of times for which to turn the vibrator on or off.repeatthe index into pattern at which to repeat, or -1 if you don't want to repeat.  重复的索引模式,或者如果你不想重复填入-1。

public abstract void vibrate (long milliseconds)

Added in API level 1

Vibrate constantly for the specified period of time.

在指定的时间内不断的震动

This method requires the caller to hold the permission VIBRATE.

这种方法要求调用方允许振动。

Parameters
millisecondsThe number of milliseconds to vibrate.
振动的毫秒数。
获取方式(Vibrator) getSystemService(VIBRATOR_SERVICE);需要权限<uses-permission  android:name="android.permission.VIBRATE"/>



0 0
原创粉丝点击