diff --git a/android_app/app/src/main/java/com/health/openscale/core/alarm/AlarmHandler.java b/android_app/app/src/main/java/com/health/openscale/core/alarm/AlarmHandler.java index 34d49821..049ac5a6 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/alarm/AlarmHandler.java +++ b/android_app/app/src/main/java/com/health/openscale/core/alarm/AlarmHandler.java @@ -17,13 +17,13 @@ package com.health.openscale.core.alarm; import android.app.AlarmManager; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Build; import android.service.notification.StatusBarNotification; -import androidx.core.app.NotificationCompat; import com.health.openscale.R; import com.health.openscale.core.datatypes.ScaleMeasurement; @@ -34,6 +34,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import androidx.core.app.NotificationCompat; import timber.log.Timber; import static android.content.Context.NOTIFICATION_SERVICE; @@ -157,7 +158,17 @@ public class AlarmHandler PendingIntent notifyPendingIntent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); - NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context); + NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "openScale_notify"); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + NotificationChannel channel = new NotificationChannel( + "openScale_notify", + "openScale weight notification", + NotificationManager.IMPORTANCE_DEFAULT); + notificationManager.createNotificationChannel(channel); + } + Notification notification = mBuilder.setSmallIcon(R.drawable.ic_launcher_openscale) .setContentTitle(context.getString(R.string.app_name)) .setContentText(notifyText)