flutter_vibration icon indicating copy to clipboard operation
flutter_vibration copied to clipboard

Fix Deprecated API Usage in Vibration Plugin for Android

Open sourav-kundu443 opened this issue 4 months ago • 0 comments

The VibrationPlugin.java file in the vibration plugin (version 2.0.1) is using or overriding deprecated APIs in Android, which triggers warnings during build. The plugin needs to be updated to use modern APIs, specifically handling Android API levels that have deprecated the older vibration methods (e.g., Vibrator.vibrate(long)).

The proposed fix is to replace the deprecated methods with newer equivalents, such as VibrationEffect.createOneShot() introduced in API level 26 (Android 8.0), while maintaining backward compatibility with older Android versions.

What to fix:

Replace deprecated Vibrator.vibrate(long) with VibrationEffect.createOneShot(long duration, int amplitude) for Android 8.0 and above.

Implement conditional logic to ensure backward compatibility for devices running Android versions below API 26.

sourav-kundu443 avatar Oct 16 '24 05:10 sourav-kundu443