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) {