android[Api]Vibrator_振动器

Class Overview


设备上的振动器控制类

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

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

Summary


Public Methods
abstract void cancel()

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

Check whether the hardware has a vibrator.

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

Vibrate with a given pattern.
振动的模式
abstract void vibrate(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
pattern an array of longs of times for which to turn the vibrator on or off.
repeat the 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
milliseconds The number of milliseconds to vibrate.
振动的毫秒数。
获取方式
(Vibrator) getSystemService(VIBRATOR_SERVICE);

需要权限
<uses-permission  android:name="android.permission.VIBRATE"/>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值