this is the code:
public class Vibrate extends AppCompatActivity {
long[] timings = {1000, 1000, 1000, 1000};
int[] amplitudes = {0, 5, 250, 5};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vibrate);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 500 milliseconds
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
v.vibrate(VibrationEffect.createWaveform(timings, amplitudes, 0));
} else {
//deprecated in API 26
v.vibrate(500);
}
}
}
I tried to a waveform effect but when i run it on my Galaxy S8 all the vibration feel the same.
What is going on?
How is it possible that amplitude of 5, and amplitude of 250 induce the same vibration?
So i did some digging and now the mystery is solved,
If anyone ever get stuck on this matter you should know that not all devices that support VibrationEffect (API>=26) actually have an Amplitude Control hardware.
To check if your device has Amplitude Control use the hasAmplitudeControl
method:
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
Log.i("================", "This device has amplitude control: " + v.hasAmplitudeControl());