Skip to content

Commit

Permalink
fix: deprication warning
Browse files Browse the repository at this point in the history
  • Loading branch information
joelJohanssonT committed Mar 19, 2024
1 parent 209492a commit 11c55b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vibration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.8.3
## 1.8.4

- Added Web support (#95 by [san-smith](https://github.com/san-smith))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.benjaminabel.vibration;

import android.content.Context;
import android.os.Build;
import android.os.Vibrator;
import android.os.VibratorManager;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
Expand Down Expand Up @@ -29,7 +31,13 @@ public void onAttachedToEngine(FlutterPluginBinding binding) {
}

private void setupChannels(BinaryMessenger messenger, Context context) {
final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
Vibrator vibrator;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
VibratorManager vibratorManager = (VibratorManager) context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE);
vibrator = vibratorManager.getDefaultVibrator();
} else {
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
}
final VibrationMethodChannelHandler methodChannelHandler = new VibrationMethodChannelHandler(new Vibration(vibrator));

this.methodChannel = new MethodChannel(messenger, CHANNEL);
Expand Down

0 comments on commit 11c55b3

Please sign in to comment.