From 3947d8b7a506f3373cfc1dcd3a4361718a13d594 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Sun, 25 May 2014 05:54:02 +0200 Subject: [PATCH] + Activity informing when app was killed while copy notifications were on --- src/keepass2android/AppKilledInfo.cs | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/keepass2android/AppKilledInfo.cs diff --git a/src/keepass2android/AppKilledInfo.cs b/src/keepass2android/AppKilledInfo.cs new file mode 100644 index 00000000..76e326e4 --- /dev/null +++ b/src/keepass2android/AppKilledInfo.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; + +namespace keepass2android +{ + [Activity(Label = AppNames.AppName)] + public class AppKilledInfo : Activity, IDialogInterfaceOnDismissListener + { + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); + //as we expect this to happen only rarely (having a foreground service running when unlocked), + //we don't try to handle this better + //But at least explain to the user what happened! + ((NotificationManager)GetSystemService(Context.NotificationService)).CancelAll(); + AlertDialog.Builder b = new AlertDialog.Builder(this); + b.SetMessage(Resource.String.killed_by_os); + b.SetPositiveButton(Resource.String.ok, delegate + { + Intent i = new Intent(this, typeof(FileSelectActivity)); + i.AddFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask); + StartActivity(i); + + }); + b.SetNegativeButton(Resource.String.cancel, delegate { }); + b.SetTitle(AppNames.AppName); + b.SetOnDismissListener(this); + var dialog = b.Create(); + dialog.Show(); + } + + public void OnDismiss(IDialogInterface dialog) + { + Finish(); + } + } +} \ No newline at end of file