SoFunction
Updated on 2025-04-10

Android Vibrator adjustment vibration code example


<!—Shock permission-->
<uses-permission android:name=""/>
//Vibrator instantiation
private Vibrator mVibrator1;
mVibrator1=(Vibrator) getApplication().getSystemService(Service.VIBRATOR_SERVICE);
 
//After waiting for 100ms, vibrate according to the values ​​given in the array; then the number of repetitions is, -1 is not repeated, 0 is vibrating all the time
(new long[]{100,10,100,1000}, -1);
 
// Vibration specified time
(2000);
 
//Cancel the vibration
();