我怎么能要求震动许可?我怎么能、许可

2023-09-05 23:31:18 作者:╰活的潇洒,笑得放肆

如何申请的震动权限在我的Andr​​oid应用程序?

How can I request the vibrate permission in my Android application?

推荐答案

下面是链接到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);
 
精彩推荐