在android开发过程当中,有的时候需要使用振动来提醒用户。

首先就要得到使用权限,在menifest.xml里面声明一下就可以了

<uses-permission android:name="android.permission.VIBRATE"/>

然后就可以在程序里面使用 振动了,下面可以得到振动效果的类

Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

最后就是控制振动时间 

vibrator.vibrate(100);

在需要的地方做上面的操作就可以完成振动的效果了。

相关文章:

  • 2022-12-23
  • 2021-06-09
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-12-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
相关资源
相似解决方案