Johan972
Johan972

Reputation: 1

How to vibrate on android oreo

I'm searching since 3 weeks and I'm going crazy! I have try every code I seen on each forum but i'm not able to have vibration on my android app on android 8.0, I have made an app with cordova, i have try to make a plugin with (vibrator) (vibrationeffect) nothing, i have try to make a blank native app with android studio, nothing. It work only on lower version of Android.

Vibration is essential for my app and I try it on 2 phone with Android 8 and I have the same problem, logcat say everythings ok, navigator.vibrate don't work because vibrate is not on touch (it's a little game).

I need your help please.

Upvotes: 0

Views: 1114

Answers (1)

Antonio Vlasic
Antonio Vlasic

Reputation: 337

1.) Initialize the Vibrator class:

 Vibrator vibrator = (Vibrator) Context.getSystemService(Context.VIBRATOR_SERVICE);

2.) Call vibrate

 vibrator.vibrate(VibrationEffect.createOneShot(30, VibrationEffect.DEFAULT_AMPLITUDE));

Upvotes: 1

Related Questions