Last active
November 13, 2017 11:33
-
-
Save nieldeokar/2ea4ff56fa9b6310c3288b8b4c4d184c to your computer and use it in GitHub Desktop.
This method would create wave form vibration using vibration effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequiresApi(api = Build.VERSION_CODES.O) | |
private void createWaveFormVibrationUsingVibrationEffectAndAmplitude() { | |
long[] mVibratePattern = new long[]{0, 400, 800, 600, 800, 800, 800, 1000}; | |
int[] mAmplitudes = new int[]{0, 255, 0, 255, 0, 255, 0, 255}; | |
// -1 : Play exactly once | |
if (vibrator.hasAmplitudeControl()) { | |
VibrationEffect effect = VibrationEffect.createWaveform(mVibratePattern, mAmplitudes, -1); | |
vibrator.vibrate(effect); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment