Open ShawnMuktadir opened 4 years ago
Not the perfect one but it works somehow
dateAndTimePicker.addOnDateChangedListener((displayed, date) -> { Vibrator vibrator = (Vibrator) Objects.requireNonNull(getContext()).getSystemService(Context.VIBRATOR_SERVICE); final long[] pattern = {0, 10}; final int[] amplitudes = {50, 50}; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { VibrationEffect effect = VibrationEffect.createWaveform(pattern, amplitudes, 0); assert vibrator != null; vibrator.vibrate(effect); (new Handler()).postDelayed(vibrator::cancel, 10); } else { assert vibrator != null; vibrator.vibrate(10); } });
works great! but, if I set delayMillis to 50, then its works perfectly, like (new Handler()).postDelayed(vibrator::cancel, 50);
Not the perfect one but it works somehow