diff --git a/src/keepass2android/app/App.cs b/src/keepass2android/app/App.cs index f35c5bd0..4e35b190 100644 --- a/src/keepass2android/app/App.cs +++ b/src/keepass2android/app/App.cs @@ -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 diff --git a/src/keepass2android/services/OngoingNotificationsService.cs b/src/keepass2android/services/OngoingNotificationsService.cs index 7eef6974..8f50025f 100644 --- a/src/keepass2android/services/OngoingNotificationsService.cs +++ b/src/keepass2android/services/OngoingNotificationsService.cs @@ -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 {