From b68f9338f27a5e75af5c8711e5512a5f20a9ad91 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 30 Dec 2015 22:15:12 +0100 Subject: [PATCH] after receiving panic trigger and locking app, remove from history This makes the app fully exit, and removes it from the Recent Apps listing. --- AndroidManifest.xml | 1 + src/com/keepassdroid/ExitActivity.java | 36 +++++++++++++++++++ .../keepassdroid/PanicResponderActivity.java | 1 + 3 files changed, 38 insertions(+) create mode 100644 src/com/keepassdroid/ExitActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 15af72b57..62da5348c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -107,6 +107,7 @@ + diff --git a/src/com/keepassdroid/ExitActivity.java b/src/com/keepassdroid/ExitActivity.java new file mode 100644 index 000000000..8a28f2b8d --- /dev/null +++ b/src/com/keepassdroid/ExitActivity.java @@ -0,0 +1,36 @@ + +package com.keepassdroid; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; + +public class ExitActivity extends Activity { + + @SuppressLint("NewApi") + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (Build.VERSION.SDK_INT >= 21) { + finishAndRemoveTask(); + } else { + finish(); + } + + System.exit(0); + } + + public static void exitAndRemoveFromRecentApps(Activity activity) { + Intent intent = new Intent(activity, ExitActivity.class); + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS + | Intent.FLAG_ACTIVITY_CLEAR_TASK + | Intent.FLAG_ACTIVITY_NO_ANIMATION); + + activity.startActivity(intent); + } +} diff --git a/src/com/keepassdroid/PanicResponderActivity.java b/src/com/keepassdroid/PanicResponderActivity.java index ce6a4e804..0f47e1a49 100644 --- a/src/com/keepassdroid/PanicResponderActivity.java +++ b/src/com/keepassdroid/PanicResponderActivity.java @@ -28,6 +28,7 @@ protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate"); App.setShutdown(); setResult(KeePass.EXIT_LOCK); + ExitActivity.exitAndRemoveFromRecentApps(this); } if (Build.VERSION.SDK_INT >= 21) {