什么是Vibrator
Vibrator是Android的震动服务,通过如下的代码获取实例。
Vibrator mVibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
简单介绍几个方法的使用:
- hasVibrator();
check whether the hardware has a viarator. - vibrate(long milliseconds)
Vibrator constantly for the specified period of time. - vibrate(long[] pattern, int repeat)
Vibrate with a given pattern.
注意别忘了加权限
<uses-permission android:name="android.permission.VIBRATE"/>