Device.vibrate()
Overview
Sends haptic feedback at intervals to the device or device scanner. This is only supported if the device provides haptic feedback.
1.2.107: added for devices with a RS6000 scanner.
2.1.38: extended to devices other than scanners.
Use Cases
• You want to provide haptic feedback on a device.
Format
Device.vibrate(vibrateTime, vibratePattern);
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
vibrateTime | The duration of the haptic feedback. | Integer | Required | Accepted values in milliseconds are any number between 0 and 2550. If values are entered for vibratePattern, then this parameter is ignored. |
vibratePattern | The pattern of haptic feedback, entered in on and off durations. | String | Optional | Accepted values in milliseconds are any number between 0 and 2550, with each value separated by a comma. Values must be entered in pairs to indicate on and off durations for each haptic. You may include up to four pairs. If no pattern is provided or an empty string is passed, the vibrateTime parameter will be used instead. |
Example 1
Copy
/* Initiate a vibration of 1000ms.
*/
Device.vibrate(1000);
Example 2
Copy
/* Initiate a vibration pattern that starts with a pause of 250ms, followed by a vibration of 500ms, another pause of 500ms, and finally a vibration of 1000ms.
*/
Device.vibrate(0, "250,500,500,1000");