Added no clear flag to ongoing notifications

This commit is contained in:
M66B
2022-04-25 08:09:39 +02:00
parent cc088cbc85
commit 7f92626ee4
4 changed files with 39 additions and 33 deletions

View File

@@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2022 by Marcel Bokhorst (M66B)
*/
import android.app.Notification;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@@ -58,8 +59,7 @@ public class ServiceExternal extends Service {
public void onCreate() {
Log.i("Service external create");
super.onCreate();
startForeground(NotificationHelper.NOTIFICATION_EXTERNAL,
getNotification().build());
startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification());
}
@Override
@@ -76,8 +76,7 @@ public class ServiceExternal extends Service {
Log.logExtras(intent);
super.onStartCommand(intent, flags, startId);
startForeground(NotificationHelper.NOTIFICATION_EXTERNAL,
getNotification().build());
startForeground(NotificationHelper.NOTIFICATION_EXTERNAL, getNotification());
if (intent == null)
return START_NOT_STICKY;
@@ -126,7 +125,7 @@ public class ServiceExternal extends Service {
return null;
}
private NotificationCompat.Builder getNotification() {
private Notification getNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "service")
.setSmallIcon(R.drawable.baseline_compare_arrows_white_24)
@@ -140,7 +139,9 @@ public class ServiceExternal extends Service {
.setLocalOnly(true)
.setOngoing(true);
return builder;
Notification notification = builder.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
return notification;
}
private static void poll(Context context, Intent intent) {