diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index a1fb19957..e594f375e 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -322,6 +322,9 @@ public class LoyaltyCardViewActivity extends AppCompatActivity { Intent shortcutIntent = new Intent(this, LoyaltyCardViewActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); + // Prevent instances of the view activity from piling up; if one exists let this + // one replace it. + shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); Bundle bundle = new Bundle(); bundle.putInt("id", id); bundle.putBoolean("view", true); diff --git a/app/src/main/java/protect/card_locker/ShortcutHelper.java b/app/src/main/java/protect/card_locker/ShortcutHelper.java index 0b9dbc137..5773e5432 100644 --- a/app/src/main/java/protect/card_locker/ShortcutHelper.java +++ b/app/src/main/java/protect/card_locker/ShortcutHelper.java @@ -103,10 +103,16 @@ class ShortcutHelper { ShortcutInfo prevShortcut = list.get(index); + Intent shortcutIntent = prevShortcut.getIntent(); + + // Prevent instances of the view activity from piling up; if one exists let this + // one replace it. + shortcutIntent.setFlags(shortcutIntent.getFlags() | Intent.FLAG_ACTIVITY_SINGLE_TOP); + ShortcutInfo updatedShortcut = new ShortcutInfo.Builder(context, prevShortcut.getId()) .setShortLabel(prevShortcut.getShortLabel()) .setLongLabel(prevShortcut.getLongLabel()) - .setIntent(prevShortcut.getIntent()) + .setIntent(shortcutIntent) .setIcon(Icon.createWithResource(context, R.drawable.circle)) .setRank(index) .build();