Android Vibrator的使用

什么是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"/>
发布了20 篇原创文章 · 获赞 25 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/u014772414/article/details/51668439