in the Androidmainfest.xml declaring vibration permissions in a file
<uses-permission android:name= "Android.permission.VIBRATE"/>
Get mobile phone vibration services through system services, such as
Vibrator vibrator= (Vibrator) Getsystemservice (Vibrator_service)
Get vibration service after detection Vibrator is present, as
Vibrator.hasvibrator ();
returns false if there is true
Make appropriate calls based on actual needs, such as
Vibrator.vibrator (long milliseconds);
Start Vibrator with the above code for a duration of milliseconds milliseconds ( ms =1 seconds)
Vibrator.vibrator (long[] pattern, int repeat);
This pattern repeat ( repeats ) starts the vibrator ( Vibration ). Use pattern in the following form :
New Long[]{a1,a2,a3,a4 ...}
In the above format, where a group of two groups, such as A1 and A2 , is a group,A3 and A4 , The previous representative of each group waits for how many milliseconds to start the vibrator, and the latter represents How many milliseconds the vibrator continues to stop, then reciprocating. Repeat represents the number of repetitions, when it is 1 , that does not repeat only once in pattern mode
Stop Vibration
Vibrator.cancel ();
Use the Vibrator class to write Android vibration in detail steps