Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I request the vibrate permission?

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

like image 969
Hardik Gajjar Avatar asked Apr 25 '11 06:04

Hardik Gajjar


People also ask

How to Add Vibration permission in Android studio?

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);


Video Answer


1 Answers

Here is the link to the reference

Add this to your manifest, as a direct child of the manifest element:

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

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); 

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); 
like image 125
Mark Mooibroek Avatar answered Oct 09 '22 02:10

Mark Mooibroek