From 8a4fa768a80706690083cb09671a8c5fa5b9abb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 11 Jul 2024 14:27:52 +0900 Subject: [PATCH] =?UTF-8?q?=E9=9D=9E=E6=8E=A8=E5=A5=A8=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=83=90=E3=82=A4=E3=83=96=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=87=A6=E7=90=86=E3=82=92=E7=BD=AE?= =?UTF-8?q?=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/example/childguard/TestService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index 65e6a2b..076175a 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -16,6 +16,7 @@ import android.graphics.Color; import android.os.Build; import android.os.Handler; import android.os.IBinder; +import android.os.VibrationEffect; import android.os.Vibrator; import android.preference.PreferenceManager; import android.util.Log; @@ -175,7 +176,10 @@ public class TestService extends Service { int flags = 0; PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, flags | PendingIntent.FLAG_IMMUTABLE); - ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(2000);//バイブレーション + Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + if (vibrator.hasVibrator()) { + vibrator.vibrate(VibrationEffect.createOneShot(2000, VibrationEffect.DEFAULT_AMPLITUDE)); + } @SuppressLint("NotificationTrampoline") NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "CHANNEL_ID") .setSmallIcon(android.R.drawable.ic_menu_info_details)