android振动效果的实现
16lz
2021-12-04
在android开发过程当中,有的时候需要使用振动来提醒用户。
首先就要得到使用权限,在menifest.xml里面声明一下就可以了
<uses-permission android:name="android.permission.VIBRATE"/>
然后就可以在程序里面使用 振动了,下面可以得到振动效果的类
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
最后就是控制振动时间
vibrator.vibrate(100);
在需要的地方做上面的操作就可以完成振动的效果了。
更多相关文章
- android:launchMode="singleTask" 与 onNewIntent(Intent intent
- Android探索之旅(第三十二篇)Android(安卓)每日get √
- declare-styleable中format详解
- Android参数传递总结
- Android(安卓)JNI实战
- android:shape的使用
- Android练习小项目时踩到的坑
- Android开发者指南(5) ―― monkeyrunner
- android:windowSoftInputMode属性使用