Steps to set up the Vibrator of your phone in Android:
a. Obtain mobile phone vibration service through system services, Vibrator vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
b. After obtaining vibration service, check whether the vibrator exists:
();
Check whether the current hardware has a vibrator, if there is a true, if there is no false.
c. Make appropriate calls according to actual needs.
(long milliseconds);
Start vibrator to last milliseconds milliseconds.
(long[] pattern, int repeat);
Repeat repeats the vibrator in pattern mode. (The form of pattern is new long[]{arg1,arg2,arg3,arg4...}, where two groups of such as arg1 and arg2 are used as a group, arg3 and arg4 are used as a group. The previous one of each group represents how many milliseconds to start the vibrator, and the latter represents how many milliseconds to stop the vibrator, and then repeat. Repeat represents the number of repetitions. When it is -1, it means that no repetition is run only once in the pattern).
();
Vibrator stops.
Notice: When using vibration service, the following permissions are required:.
a. Obtain mobile phone vibration service through system services, Vibrator vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
b. After obtaining vibration service, check whether the vibrator exists:
();
Check whether the current hardware has a vibrator, if there is a true, if there is no false.
c. Make appropriate calls according to actual needs.
(long milliseconds);
Start vibrator to last milliseconds milliseconds.
(long[] pattern, int repeat);
Repeat repeats the vibrator in pattern mode. (The form of pattern is new long[]{arg1,arg2,arg3,arg4...}, where two groups of such as arg1 and arg2 are used as a group, arg3 and arg4 are used as a group. The previous one of each group represents how many milliseconds to start the vibrator, and the latter represents how many milliseconds to stop the vibrator, and then repeat. Repeat represents the number of repetitions. When it is -1, it means that no repetition is run only once in the pattern).
();
Vibrator stops.
Notice: When using vibration service, the following permissions are required:.