benjamindean / flutter_vibration

Handle vibration on iOS and Android in Flutter apps
229 stars 69 forks source link

Vibration is not working on Android 10 #20

Closed DhavalRKansara closed 4 years ago

DhavalRKansara commented 4 years ago

Vibration is not working for Android 10

I have already added below the line in my AndroidManifest.xml: <uses-permission android:name="android.permission.VIBRATE"/>

Code for Vibration:

if (Vibration.hasVibrator() != null) {
     if (Vibration.hasAmplitudeControl() != null) {
          Vibration.vibrate(duration: 500,amplitude: 128,);
      } else {
          Vibration.vibrate();
      }
}

In case of Android 10 hasAmplitudeControl condition is satisfied and also there is no error but still, the device is not vibrating.

benjamindean commented 4 years ago

I'm unable to test it on Android 10 at the moment. Is there anything related to vibration in logs?

DhavalRKansara commented 4 years ago

No, there is no error in the logs. But I think you will have to test and provide a solution for android 10 because nowadays more than enough android devices are upgrading to Android 10.

benjamindean commented 4 years ago

True. I'll find some way to test it then.

DhavalRKansara commented 4 years ago

True. I'll find some way to test it then.

@benjamindean I tried this library in multiple devices with Android 10 and vibration is not working in only Pixel 3 xl device. Apart from this I tried in Samsung M20, Pixel and Oneplus 6 and the vibration is working fine on these phones with Android 10. So I am closing the issue because it seems to be a device-specific issue.

nohli commented 3 years ago

In case that anyone else encounters the same problem: Battery Saver seems to disable haptic feedback. Turn it off and it vibrates.