Android Mobile phone Vibration settings (vibrator) steps to briefly explain _android
Source: Internet
Author: User
Android mobile phone vibration settings (vibrator) Steps:
A, through the system services to obtain mobile phone vibration services, vibrator vibrator = (Vibrator) getsystemservice (Vibrator_service);
b, after the vibration service to detect the existence of vibrator:
Vibrator.hasvibrator ();
Detects if the current hardware has vibrator and returns true if it has not returned false.
C, appropriate calls are made according to the actual needs,
Vibrator.vibrate (long milliseconds);
Start vibrator continues milliseconds milliseconds.
Vibrator.vibrate (long[] pattern, int repeat);
Repeat repeat to start vibrator in pattern mode. (Pattern in the form of new Long[]{arg1,arg2,arg3,arg4 ...}, where a group of two, such as Arg1 and Arg2 as a group, ARG3 and Arg4 as a set, the previous representative of each group waiting for how many milliseconds to start vibrator, The latter represents how many milliseconds the vibrator continues to stop, and then back and forth. Repeat represents the number of repetitions, and when it is-1, it does not repeat to run only once in pattern.
Vibrator.cancel ();
Vibrator Stop.
Note : The use of shock services requires the following permissions: Android.permission.VIBRATE.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.