From d723165b76de17644eacf36f190e58a091944c64 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:22:28 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E6=AF=94=E8=BC=83?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4(=E3=82=A2=E3=83=97=E3=83=AA?= =?UTF-8?q?=E3=81=AE=E8=A6=81=E6=B1=82API=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=8C=E3=82=82=E3=81=A8=E3=82=82=E3=81=A8?= =?UTF-8?q?26(=3D8.0(=3DOreo))=E3=81=AE=E3=81=9F=E3=82=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/TestService.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index 7a69b01..e616227 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -181,22 +181,20 @@ public class TestService extends Service { .setPriority(NotificationCompat.PRIORITY_HIGH) // プライオリティを高く設定 .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); // ロック画面に表示する - // NotificationChannelの作成(Android 8.0以降) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationManager notificationManager = context.getSystemService(NotificationManager.class); - if (notificationManager != null) { - NotificationChannel channel = new NotificationChannel( - CHANNEL_ID, - "Channel Name", - NotificationManager.IMPORTANCE_HIGH - ); + // 通知チャンネルの作成 + NotificationManager notificationManager = context.getSystemService(NotificationManager.class); + if (notificationManager != null) { + NotificationChannel channel = new NotificationChannel( + CHANNEL_ID, + "Channel Name", + NotificationManager.IMPORTANCE_HIGH + ); - channel.setDescription("Channel Description"); - channel.enableLights(true); - channel.setLightColor(Color.RED); - channel.enableVibration(true); - notificationManager.createNotificationChannel(channel); - } + channel.setDescription("Channel Description"); + channel.enableLights(true); + channel.setLightColor(Color.RED); + channel.enableVibration(true); + notificationManager.createNotificationChannel(channel); }