From b6c1bbd213169732661d19b6ebe4f8f8a48c81bd 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 16:53:22 +0900 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5ID=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/childguard/TestService.java | 13 +++++++++---- 1 file changed, 9 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 48f0ac3..6794147 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -36,8 +36,9 @@ public class TestService extends Service { private final String title; private final String description; private final String channelId; + private final int notificationId; - public NotificationContent(String title, String description, String channelId) { + public NotificationContent(String title, String description, String channelId, int notificationId) { this.title = title; this.description = description; this.channelId = channelId; @@ -54,6 +55,10 @@ public class TestService extends Service { public String getChannelId() { return channelId; } + + public int getNotificationId() { + return notificationId; + } } public static final String TAG = "InspirationQuote"; @@ -65,9 +70,9 @@ public class TestService extends Service { // DEBUG private static final int NOTIFICATION_DELAY = 5 * 1000; // 15 seconds private static final NotificationContent REPORTED_NOTIFICATION = - new NotificationContent("子供の置き去りをしていませんか?", "第三者からの通報が行われました。", REPORTED_CHANNEL_ID); + new NotificationContent("子供の置き去りをしていませんか?", "第三者からの通報が行われました。", REPORTED_CHANNEL_ID, 1); private static final NotificationContent BLUETOOTH_NOTIFICATION = - new NotificationContent("子供の置き去りをしていませんか?", "Bluetoothと車の切断から5分が経過しました", BT_ALERT_CHANNEL_ID); + new NotificationContent("子供の置き去りをしていませんか?", "Bluetoothと車の切断から5分が経過しました", BT_ALERT_CHANNEL_ID, 2); private String userId = null; @@ -280,7 +285,7 @@ public class TestService extends Service { NotificationManager notificationManager = context.getSystemService(NotificationManager.class); - notificationManager.notify(R.string.app_name, builder.build());//通知の表示 + notificationManager.notify(content.getNotificationId(), builder.build()); } private final BroadcastReceiver receiver = new BroadcastReceiver() {