From e53fdb04b963c5b4a168cb035d0903a8319d70ff 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 15:05:46 +0900 Subject: [PATCH] =?UTF-8?q?Warn=E5=AF=BE=E5=87=A6(=E7=9C=9F=E5=81=BD?= =?UTF-8?q?=E5=8F=8D=E8=BB=A2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/TestService.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/example/childguard/TestService.java b/app/src/main/java/com/example/childguard/TestService.java index 7b36e45..44cc156 100644 --- a/app/src/main/java/com/example/childguard/TestService.java +++ b/app/src/main/java/com/example/childguard/TestService.java @@ -12,8 +12,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; -import android.graphics.Color; -import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.VibrationEffect; @@ -29,9 +27,6 @@ import androidx.core.app.NotificationManagerCompat; import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.FirebaseFirestore; -import java.util.HashMap; -import java.util.Map; - public class TestService extends Service { FirebaseFirestore db; DocumentReference mDocRef; @@ -92,9 +87,15 @@ public class TestService extends Service { * 通知が許可がされているかどうかを確認 * @return 通知の許可の有無 true: 許可されている false: 許可されていない */ - private boolean isNotificationEnabled() { + private boolean isNotNotificationEnabled() { NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this); - return notificationManagerCompat.areNotificationsEnabled(); + if (!notificationManagerCompat.areNotificationsEnabled()) { + Log.d(TAG, "通知が許可されていません"); + return true; + } else { + Log.d(TAG, "通知が許可されています"); + return false; + } } private void initNotification(DocumentReference mDocRef) {//サイト上で押されたボタンの管理 @@ -153,7 +154,7 @@ public class TestService extends Service { public void Notification(Context context) {//実際に通知を行うメソッド // 権限の保有を確認 - if (!isNotificationEnabled()) return; + if (isNotNotificationEnabled()) return; vibrateDevice(); @@ -174,7 +175,7 @@ public class TestService extends Service { public void NotificationBluetooth(Context context) {//実際に通知を行うメソッド // 権限の保有を確認 - if (!isNotificationEnabled()) return; + if (isNotNotificationEnabled()) return; vibrateDevice();