attempt to make OngoingNotificationsService compatible to Android 8 restrictions

This commit is contained in:
Philipp Crocoll
2018-06-05 21:35:03 +02:00
parent 513ea5a198
commit a10c474ce5
2 changed files with 6 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ using KeePassLib.Keys;
using KeePassLib.Serialization;
using Android.Preferences;
using Android.Support.V4.App;
using Android.Support.V4.Content;
#if !EXCLUDE_TWOFISH
using TwofishCipher;
#endif
@@ -244,7 +245,7 @@ namespace keepass2android
public static void StartOnGoingService(Context ctx)
{
ctx.StartService(new Intent(ctx, typeof (OngoingNotificationsService)));
ContextCompat.StartForegroundService(ctx, new Intent(ctx, typeof (OngoingNotificationsService)));
}
public bool DatabaseIsUnlocked

View File

@@ -65,11 +65,11 @@ namespace keepass2android
// Set the icon to reflect the current state
if (App.Kp2a.DatabaseIsUnlocked)
{
// Clear current foreground status and QuickUnlock icon
StopForeground(true);
// Clear QuickUnlock icon
notificationManager.Cancel(QuickUnlockId);
//use foreground again to let the app not be killed too easily.
StartForeground(UnlockedWarningId, GetUnlockedNotification());
//use foreground again to let the app not be killed too easily.
StartForeground(UnlockedWarningId, GetUnlockedNotification());
}
else
{