1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-18 14:31:23 +02:00

added notification channel for Android O

This commit is contained in:
oliexdev
2019-02-03 19:23:17 +01:00
parent d5a119a117
commit 65ca09ea2e

View File

@@ -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)