From e77b50eee3326201372d01a694b200bf283919e8 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:25:05 +0900 Subject: [PATCH] =?UTF-8?q?=E6=A8=A9=E9=99=90=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=AF=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE?= =?UTF-8?q?=E6=9C=80=E5=88=9D=E3=81=A7=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/example/childguard/TestService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index c22f70a..65e6a2b 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -161,6 +161,11 @@ public class TestService extends Service { } public void NotificationBluetooth(Context context) {//実際に通知を行うメソッド + + // 権限の保有を確認 + if (ActivityCompat.checkSelfPermission(this, + android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) return; + final String CHANNEL_ID = "my_channel_id"; // 通知がクリックされたときに送信されるIntent Intent intent = new Intent(context, MainActivity.class); @@ -196,10 +201,6 @@ public class TestService extends Service { channel.enableVibration(true); notificationManager.createNotificationChannel(channel); } - - if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { - return; - } notificationManager.notify(R.string.app_name, builder.build());//通知の表示 }