我怎么能要求震动许可? [英] How can I request the vibrate permission?
本文介绍了我怎么能要求震动许可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何申请的震动权限在我的Android应用程序?
How can I request the vibrate permission in my Android application?
推荐答案
下面是链接到<一个href="http://developer.android.com/reference/android/Manifest.permission.html#VIBRATE">reference
添加到您的清单,作为清单
元素的直接子:
Add this to your manifest, as a direct child of the manifest
element:
<uses-permission android:name="android.permission.VIBRATE" />
这是你如何让手机震动直通code:
This is how you let the phone Vibrate thru code:
// Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 300 milliseconds
v.vibrate(300);
对于一个更有创意的方式尝试星球大战主题= D
For a more creative pattern try the star wars theme =D
v.vibrate(new long[]{0, 500, 110, 500, 110, 450, 110, 200, 110, 170, 40, 450, 110, 200, 110, 170, 40, 500}, -1);
这篇关于我怎么能要求震动许可?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文