Skip to content

Commit

Permalink
after receiving panic trigger and locking app, remove from history
Browse files Browse the repository at this point in the history
This makes the app fully exit, and removes it from the Recent Apps listing.
  • Loading branch information
eighthave committed Jun 24, 2016
1 parent 25c3f8f commit 54549e7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.keepassdroid.ExitActivity" android:theme="@android:style/Theme.NoDisplay"></activity>
<activity android:name="com.keepassdroid.settings.AppSettingsActivity"
android:theme="@style/NoTitleBar"></activity>
<activity android:name="com.keepassdroid.GeneratePasswordActivity"
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/java/com/keepassdroid/ExitActivity.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (intent != null && PANIC_TRIGGER_ACTION.equals(intent.getAction())) {
App.setShutdown();
setResult(KeePass.EXIT_LOCK);
ExitActivity.exitAndRemoveFromRecentApps(this);
}

if (Build.VERSION.SDK_INT >= 21) {
Expand Down

0 comments on commit 54549e7

Please sign in to comment.