android振动效果的实现

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

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

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

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

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

最后就是控制振动时间 

vibrator.vibrate(100);

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

posted @ 2012-06-15 17:34  幻星宇  阅读(210)  评论(0编辑  收藏  举报